This PHP function will assist in splitting a string based on characters.
$string = "This istan examplenstring"; /* Use tab and newline as tokenizing characters as well */ $tok = strtok($string, " nt"); while ($tok !== false) { echo "Word=$tok<br />"; $tok = strtok(" nt"); }
$first_token = strtok('/something', '/'); $second_token = strtok('/'); var_dump($first_token, $second_token);
string(0) "" string(9) "something"
$first_token = strtok('/something', '/'); $second_token = strtok('/'); var_dump($first_token, $second_token);
string(9) "something" bool(false)
Source: http://www.php.net/manual/en/function.strtok.php
Last Updated on October 26, 2015