PHP strtok() Function
Example
Split a string by words:
In the example below, note that we use the string parameter only on the first call to the strtok() function. After the first call, the function only needs the split parameter, because it knows its position in the current string. To split a new string, call strtok() again with the string parameter:
" ; $token = strtok ( " " ) ; } ?>Run Example »
Definition and Usage
The strtok() function splits a string into smaller strings (tokens).
Syntax
strtok(
string,split
)
| Parameters | Description |
|---|---|
| string | Required. Specifies the string to split. |
| split | Required. Specifies one or more split characters. |
Technical Details
| Return Value: | Returns the string token. |
|---|---|
| PHP Version: | 4+ |
PHP String Reference Manual