Home>Article>Backend Development> How to use php strspn function?

How to use php strspn function?

青灯夜游
青灯夜游 Original
2019-05-30 11:06:54 2683browse

The strspn() function is a built-in function in PHP. The syntax is strspn(string,charlist,start,length). It is used to return the number of characters specified in the charlist parameter in the string.

How to use php strspn function?

php How to use strspn() function?

strspn() function returns the number of characters specified in the charlist parameter in a string.

Syntax:

strspn(string,charlist,start,length)

Parameters:

● String: Required. Specifies the string to be searched for.

●Charlist: Required. Specifies the characters to search for.

● start: optional. Specifies where in the string to begin.

●length: optional. Defines the length of the string.

Return value:Returns the number of characters specified in the charlist parameter contained in the string.

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

php strspn() function example 1:

Output:

5

php strspn() function example 2:

Output:

3

The above is the detailed content of How to use php strspn 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