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 159 views
3 answers 244 views
3 answers 278 views
1 answer 212 views
1 answer 229 views
3 answers 271 views
2 answers 175 views
...