PHP strtok () function
Examples
Press split the string of words:
In the following examples, please note that we are only at the first call to strtok () function when using the string parameter. After the first call, this function only needs the split argument, because it is clear where their own position in the current string. To split a new string, please call strtok with the string argument again ():
<?php
$string = "Hello world. Beautiful day today.";
$token = strtok($string, " ");
while ($token != false)
{
echo "$token<br>";
$token = strtok(" ");
}
?>
$string = "Hello world. Beautiful day today.";
$token = strtok($string, " ");
while ($token != false)
{
echo "$token<br>";
$token = strtok(" ");
}
?>
Running instance »
Definition and Usage
strtok () function to split a string into smaller strings (tag).
grammar
strtok( string,split )
参数 | 描述 |
---|---|
string | 必需。规定要分割的字符串。 |
split | 必需。规定一个或多个分割字符。 |
technical details
return value: | Returns a string tag. |
---|---|
PHP version: | 4+ |
PHP String Reference