Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP strtok() Function

PHP strtok() Function

PHP String Reference Manual PHP String Reference Manual

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 PHP String Reference Manual