Use more than one delimiter to split string : String Token « String « PHP






Use more than one delimiter to split string

<?php
   $info = "J. G:joe@java2s.com|Vancouver, BC";
   // 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);
   }
?>



           
       








Related examples in the same category

1.String token for string split
2.String token: space
3.String string token value
4.Dividing a String into Tokens with strtok()