is_iterable

Verify that the contents of a variable is an iterable value

Syntax

is_iterable ( mixed $var ) : bool

Parameters

var

The value to check

Return

Returns TRUE if var is iterable, FALSE otherwise.

Examples

1

<?

$var = array();

$return = is_iterable($var);

echo $return;

?>
1

2

<?

$var = array(0, 1);

$return = is_iterable($var);

echo $return;

?>
1

3

<?

$var = new ArrayIterator();

$return = is_iterable($var);

echo $return;

?>
1

4

<?

$array = array(0, 1);

$var = new ArrayIterator($array);

$return = is_iterable($var);

echo $return;

?>
1

5

<?

$var = (function() { yield 1; })();

$return = is_iterable($var);

echo $return;

?>
1

PHP

Home Menu