Easy Tutorial
❮ Func Mysqli Thread Safe Func Mysqli Ping ❯

PHP strtok() Function

PHP String Reference Manual

Example

Splitting a string by words:

In the following example, note that we only used the string parameter in the first call to the strtok() function. After the initial call, the function only requires the split parameter because it knows its position in the current string. To split a new string, call strtok() again with the string parameter:

<?php
$string = "Hello world. Beautiful day today.";
$token = strtok($string, " ");

while ($token !== false)
{
    echo "$token<br>";
    $token = strtok(" ");
} 
?>

Definition and Usage

The strtok() function splits a string into smaller strings (tokens).


Syntax

Parameter Description
string Required. Specifies the string to split.
split Required. Specifies one or more split characters.

Technical Details

Return Value: Returns the string token.
PHP Version: 4+
--- ---
❮ Func Mysqli Thread Safe Func Mysqli Ping ❯