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 210 views
1 answer 138 views
1 answer 149 views
1 answer 153 views
1 answer 215 views
215 views asked Aug 7, 2021 by avibootz
1 answer 198 views
198 views asked Aug 7, 2021 by avibootz
1 answer 231 views
231 views asked Aug 7, 2021 by avibootz
...