The ctype_digit() function check for numeric character(s). It checks if all of the characters in the provided string, text, are numerical.
Syntax
ctype_digit(str)
Parameters
str − The tested string
Return
The ctype_digit() function returns TRUE if every character in text is a decimal digit, FALSE otherwise.
Example
The following is an example −
<?php $arr = array('mac7687', '8798'); foreach ($arr as $a) { if (ctype_digit($a)) { echo "$a has all digits. \n"; } else { echo "$a does not have all digits. \n"; } } ?>
Output
The following is the output −
mac7687 does not have all digits. 8798 has all digits.