1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
$info = "J. Gilmore:jason@example.com|Columbus, Ohio";
// delimiters include colon (:), vertical bar (|), and comma (,)
$tokens = ":|,";
$tokenized = strtok($info, $tokens);
// print out each element in the $tokenized array
while ($tokenized) {
echo "Element = $tokenized<br>";
// Don't include the first argument in subsequent calls.
$tokenized = strtok($tokens);
}
?>
This returns the following:
Element = J. Gilmore
Element = jason@example.com
Element = Columbus
Element = Ohio |