Home > Article > Backend Development > How to use php strtok function
PHP strtok function is used to split strings one by one. Its syntax is strtok(string,split). The parameter string is required and refers to specifying the string to be split; split is required and refers to specifying one or more splitting characters.
php How to use strtok function?
php strtok() function syntax
Function: Split characters one by one String
Syntax:
strtok(string,split)
Parameters:
string Required. Specifies the string to be split.
split Required. Specifies one or more delimiting characters.
Description:
strtok() function splits a string into smaller strings (markers).
php strtok() function example
<?php $string = "Hello world. I'm study in php.cn!"; $token = strtok($string, "."); while ($token !== false) { echo "$token<br>"; $token = strtok("."); } ?>
Output:
Hello world I'm study in php cn!
This article is an introduction to the PHP strtok function. I hope it will be helpful to friends who need it. Helps!
The above is the detailed content of How to use php strtok function. For more information, please follow other related articles on the PHP Chinese website!