Definition
The strtok() function splits a string into smaller strings (tokens).
Syntax
strtok(string, split)
Parameters
Parameter | Description |
---|---|
string |
Required. Specifies the string to split. |
split |
Required. Specifies one or more split characters. |
Example
<?php
$str = "Welcome to the PHP Tutorials. Learn PHP quickly.";
$tokens = strtok($str, " ");
while ($tokens !== false) {
echo "$tokens<br>";
$tokens = strtok(" ");
}