How to check if an array contains only strings in PHP

1 Answer

0 votes
$arr = array("php", "c", "c++", "java");

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

 



answered Mar 4, 2019 by avibootz
...