Tokenize a string by :,| in PHP
Description
The following code shows how to tokenize a string by :,|.
Example
<?php/*www .j a v a 2 s .c o m*/
$info = "J. jack:j@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);
}
?>
The code above generates the following result.