How to check if strings in array are alphanumeric in PHP

1 Answer

0 votes
$arr = array('3.14', '9893', 'F16');

foreach ($arr as $s) {
    if (ctype_alnum($s)) {
        echo "true<br />";
    }
    else {
       echo "false<br />"; 
    }
}
      
 
  
    
/*
run:
         
false
true
true
  
*/

 



answered Aug 17, 2019 by avibootz
...