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.
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!