Easy Tutorial
❮ Php Is_Resource Function Func Mysqli Error ❯

PHP is_iterable() Function

PHP Available Functions

The is_iterable() function is used to check if a variable is an iterable value.

PHP Version Requirement: PHP 7 >= 7.1.0

Syntax

bool is_iterable ( mixed $var )

Parameter Description:

Return Value

Returns TRUE if the specified variable is an iterable object, otherwise returns FALSE.

Example

<?php
var_dump(is_iterable([1, 2, 3]));  // bool(true)
var_dump(is_iterable(new ArrayIterator([1, 2, 3])));  // bool(true)
var_dump(is_iterable((function () { yield 1; })()));  // bool(true)
var_dump(is_iterable(1));  // bool(false)
var_dump(is_iterable(new stdClass()));  // bool(false)
?>

Output:

bool(true)
bool(true)
bool(true)
bool(false)
bool(false)

PHP Available Functions

❮ Php Is_Resource Function Func Mysqli Error ❯