PHP strspn() Function

PHP strspn() Function

The strspn() function of PHP finds the length of the initial segment of string that contains only characters from the mask parameter.

Syntax

Parameter

subject(required)– This parameter represents the input string.

mask(required)– This parameter specifies the characters to find.

start (optional)- It signifies the position in the string to start searching.

length(optional)– This parameter represents the length of the segment from subject to examine. If length is positive, then string will be examined for length characters after the starting position else for negative length the subject will be examined from the starting position.

Return

This function returns the length of the initial segment of subject only characters from the mask parameter.

Example 1

Output

Example 2

Output

Example 3

Output

Example 4

Output