PHP/String/strspn
Содержание
strcspn demo
<source lang="html4strict">
<?php
$password = "a12345"; if (strcspn($password, "1234567890") == 0) { print "Password cannot consist solely of numbers! "; }
?>
</source>
strcspn() function returns the length of the first segment in string1 containing characters not in string2.
<source lang="html4strict">
Its syntax is: int strcspn (string str1, string str2) <? $password = "12345"; if (strcspn($password, "1234567890") == 0) :
print "Password cannot consist solely of numbers!";
endif; ?>
</source>
strspn() function returns the length of the first segment in string1 containing characters also in string2.
<source lang="html4strict">
Its syntax is: int strspn (string string1, string string2) <? $password = "12345"; if (strspn($password, "1234567890") != strlen($password)) :
print "Password cannot consist solely of numbers!";
endif; ?>
</source>
strspn.php
<source lang="html4strict">
<?php
$password = "1111111"; if (strspn($password, "1234567890") == strlen($password)) echo "The password cannot consist solely of numbers!";
?>
</source>