PHP strspn Function

What is strspn Function?


In PHP this function returns the number of characters found in the string that contains only characters from the charlist.



The above syntax specifes the "string" to be search, "char" specifies the characters to be searched for, "start" specifes where to start search,"length" specifes the length of the string.

Example :

echo strspn("42 code for the question...", "1234567890");
Result :


In the above strspn function example only 2 characters from the character list is present in the string, hence returns "2".

PHP Topics

Ask Questions

Ask Question