|
|
Tutorials » Php »
|
Topic |
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, " \n\t");
while ($tok !== false)
{
echo "Word=$tok <br/>";
$tok = strtok(" \n\t");
}
?>
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.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|