search
HomeBackend DevelopmentPHP ProblemHow to use php strtok() function

How to use php strtok() function

Jul 05, 2021 pm 06:38 PM
phpstrtok function

In PHP, the strtok() function is used to split a string into smaller strings (marks) according to the specified delimiter, and then return the string mark; the syntax format is "strtok(string, separator)".

How to use php strtok() function

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

PHP strtok() is used to based on the given Delimiter marks the string into smaller parts, it takes the input string as an argument along with the delimiter (as the second argument).

Syntax

strtok(string,split)
##ParametersDescriptionRequired. Specifies the string to be split. Required. Specifies one or more delimiting characters.
string
split

Description:

This function returns a string or a range of strings separated by the given delimiter. A sequence of strings can be found by using strtok() in a while loop.

Example:

<?php
$string = "Hello world !";
  $token = strtok($string, " ");
while ($token != false)
    {
    echo "$token<br>";
    $token = strtok(" ");
    }
?>

Output:


Hello
world
!

Recommended learning: "

PHP Video Tutorial"

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools