How to check if an array contains only integers in PHP

1 Answer

0 votes
$arr = array(1, 2, 3, 4, 5, 6, 7);

if (array_filter($arr, 'is_int') === $arr) {
    echo "yes";
}
else {
    echo "no";
}
   
    
/*
run:
     
yes
     
*/

 



answered Mar 4, 2019 by avibootz
...