How to check if variable is array in PHP

2 Answers

0 votes
$arr = array("php"=>"99", "c"=>"108", "c++"=>"31");

if (is_array($arr)) {
    echo "yes";
}
else {
    echo "no";
}

 
 
 
/*
run:
 
yes

*/

 



answered Jul 1, 2022 by avibootz
0 votes
$arr = [4, 5, 7, 0, 1];
 
if (is_iterable($arr)) {
    echo "yes";
}
else {
    echo "no";
}
 
  
  
  
/*
run:
  
yes
 
*/

 



answered Dec 11, 2023 by avibootz

Related questions

1 answer 167 views
3 answers 250 views
3 answers 283 views
1 answer 217 views
1 answer 233 views
3 answers 277 views
2 answers 186 views
...