Checks character occurrences in a string.
This function is similar to strspn(), but strcspn() returns how far, as a number of characters, into the first string no characters from the second string appear.
<?php
$digits = implode(range(0, 9));
$passwd = "secret";
if (strcspn($passwd, $digits) == strlen($passwd)) {
print "Password must contain digits also.";
} else {
print "Password is legal";
}
?>
Password must contain digits also.
strcspn() is used to check that a password contains digits.