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 208 views
1 answer 136 views
1 answer 148 views
1 answer 152 views
1 answer 214 views
214 views asked Aug 7, 2021 by avibootz
1 answer 196 views
196 views asked Aug 7, 2021 by avibootz
1 answer 224 views
224 views asked Aug 7, 2021 by avibootz
...