Home  >  Article  >  Backend Development  >  How to use php strtok function

How to use php strtok function

藏色散人
藏色散人Original
2019-02-01 10:00:312520browse

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.

How to use php strtok function

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&#39;m study in php.cn!";
$token = strtok($string, ".");
while ($token !== false)
{    
echo "$token<br>";    
$token = strtok(".");
}
?>

Output:

Hello world
I&#39;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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn