You are here : phpstringstrtok

strtok() - string

strtok() splits a string (str)
   into smaller strings (tokens), with each token being delimited by any
   character from token.
   That is, if you have a string like "This is an example string" you
   could tokenize this string into its individual words by using the
   space character as the token.
Parameters :
  • str - The string being split up into smaller strings (tokens).
  • token - The delimiter used when splitting up str.

  • Syntax

    string strtok
        ( string $str
       , string $token
       )


    Example

    <?php$string = "This is\tan example\nstring";/* Use tab and newline as tokenizing characters as well  */$tok = strtok($string, " \n\t");while ($tok !== false) {    echo "Word=$tok<br />";    $tok = strtok(" \n\t");}?>


    Output / Return Value


    Limitations


    Alternatives / See Also


    Reference