strspn()

It returns the number of characters found in the string that contains only characters from the charlist.

Example

<?php
echo strspn(“phpcodephp”,”phpe”);
?>

Output

3