How to use php strtok function

藏色散人
Release: 2023-04-05 06:12:02
Original
2565 people have browsed it

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)
Copy after login

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(".");
}
?>
Copy after login

Output:

Hello world
I&#39;m study in php
cn!
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template