is_iterable
Verify that the content of the variable is an iterable value
is_iterable()
function checks whether the content of the variable is an iterable value.
If the variable is iterable, the function returns true
(1), otherwise false
/ no return value.
Check whether the content of the variable is an iterable value:
<?php $a = "Hello" ; echo "a is " . is_iterable ( $a ) . "<br>" ; $b = array ( "red" , "green" , "blue" ) ; echo "b is " . is_iterable ( $b ) . "<br>" ; $c = array ( "Peter" => "35" , "Ben" => "37" , "Joe" => "43" ) ; echo "c is " . is_iterable ( $c ) . "<br>" ; $d = [ 1 , 2 , 3 ] ; echo "d is " . is_iterable ( $d ) . "<br>" ; ?>
Try it yourself
is_iterable ( variable ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |