Home > Article > Backend Development > strspn function example tutorial_PHP tutorial
Definition and usage
The strspn() function returns the number of characters found in the string containing only characters from the charlist.
Grammar
strspn(string,charlist,start,length)
Parameters
Description
string: required. Specify string search
charlist:request. The specified character is found
start: optional. Where the specified string starts
length: optional. String prompts and instructions of specified length Note: This feature is binary safe.
Example 1
echo strspn("Hello world!","kHlleo");
?>
The result is: 5
Let’s look at another strspn tutorial.
echo strspn("abcdefand","abc");
?>
The result is 3