is_array
Detect whether a variable is an array
is_array()
function checks whether the variable is an array.
If the variable is an array, the function returns true
(1), otherwise false/none (returns nothing).
Check if the variable is an array:
<?php $a = "Hello" ; echo "a is " . is_array ( $a ) . "<br>" ; $b = array ( "red" , "green" , "blue" ) ; echo "b is " . is_array ( $b ) . "<br>" ; $c = array ( "Peter" => "35" , "Ben" => "37" , "Joe" => "43" ) ; echo "c is " . is_array ( $c ) . "<br>" ; $d = "red, green, blue" ; echo "d is " . is_array ( $d ) . "<br>" ; ?>
Try it yourself
is_array ( variable ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |