What is the isdigit() equivalent in PHP

1 Answer

0 votes
$s = "PHP 9";
           
if (ctype_digit($s[1])) 
    echo "digit" . "\n";
else
    echo "not digit" . "\n";
    
if (ctype_digit($s[4])) 
    echo "digit" . "\n";
else
    echo "not digit" . "\n";    
 
 
 
 
 
/*
run:
 
not digit
digit
 
*/

 



answered Aug 7, 2021 by avibootz

Related questions

3 answers 202 views
1 answer 127 views
1 answer 138 views
1 answer 143 views
1 answer 204 views
204 views asked Aug 7, 2021 by avibootz
1 answer 188 views
188 views asked Aug 7, 2021 by avibootz
1 answer 211 views
211 views asked Aug 7, 2021 by avibootz
...