strtok() function tokenizes string, using the characters specified in tokens. : strtok « String « PHP






strtok() function tokenizes string, using the characters specified in tokens.

 
Its syntax is: string strtok (string string, string tokens)

<?
$info = "WJ asdf asdf sdf";

// delimiters include colon (:), vertical bar (|), and comma (,)
$tokens = ":|,";

$tokenized = strtok($info, $tokens);
while ($tokenized) :
     echo "Element = $tokenized<br>";
     $tokenized = strtok ($tokens);
endwhile;
?>
  
  








Related examples in the same category

1.strtok() function performs a similar task to explode()
2.strtok.php
3.Dividing a String into Tokens with strtok()