How to use php strcspn function?

青灯夜游
Release: 2023-02-22 22:30:02
Original
2388 people have browsed it

The strcspn() function is a built-in function in PHP. The syntax is strcspn(string,char,start,length). It is used to return the number of characters (including spaces) found in the string before any specified characters are found. . This function is case-sensitive.

How to use php strcspn function?

php How to use strcspn() function?

The strcspn() function returns the number of characters (including spaces) searched in the string before any specified character is found.

Syntax:

strcspn(string,char,start,length)
Copy after login

Parameters:

● string: required. Specifies the string to search for.

●Char: required. Specifies the characters to search for.

● start: optional. Specifies the location to start the search.

●length: optional. Specifies the length of the string (how many characters to search for).

Return value:Returns the number of characters (including spaces) found in the string before any specified characters are found.

Let’s take a look at how to use the php strcspn() function through an example.

php strcspn() function example 1:

Copy after login

Output:

6
Copy after login

php strcspn() function example 1:

Copy after login

Output:

9
Copy after login

The above is the detailed content of How to use php strcspn function?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!