PHP strtok Function
What is strtok Function?
Explanation
In PHP this function is used to tokenize a string.
Syntax:
strtok(string,split)
The above syntax specifies the string to be split to one or more split characters.
Example :
<?php
$str = "Hi nHow Are tYou";
$tok = strtok($str, " nt");
while ($tok !== false)
{
echo "Word=$tok <br/>";
$tok = strtok(" nt");
}
?>
Result :
Word=Hi
Word=How
Word=Are
Word=You
In the above strtok function example the string is split using the tab "t", newline "n" characters.