Current Location: Home> Function Categories> is_iterable

is_iterable

Verify that the content of the variable is an iterable value
Name:is_iterable
Category:Variable processing
Programming Language:php
One-line Description:Checks whether the content of the variable is an iterable value.

Definition and usage

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.

Example

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

grammar

 is_iterable ( variable ) ;
parameter describe
variable Required. Specifies the variable to check.
Similar Functions
Popular Articles