very dificult to get from the definition directly, while i search for that,i came to know that
strspn() will tell you the length of a string consisting entirely of the set of characters in accept set. That is, it starts walking down str until it finds a character that is not in the set (that is, a character that is not to be accepted), and returns the length of the string so far.
strcspn() works much the same way, except that it walks down str until it finds a character in the reject set (that is, a character that is to be rejected.) It then returns the length of the string so far.
$acceptSet = "aeiou";
$rejectSet = "y";
$str1 ="a banana";
$str2 ="the bolivian navy on manuvers in the south pacific";
echo $n = strspn($str1,$acceptSet);echo $n = strcspn($str2,$rejectSet);?>
hope this example will help in understanding the concept of strspn() and strcspn().