is_iterable()WP 1.0

Polyfill for is_iterable() function added in PHP 7.1.

1 time — 0.000001 sec (speed of light) | 50000 times — 0.01 sec (speed of light) | PHP 7.1.11, WP 4.9.8

No Hooks.

Return

null. Nothing (null).

Usage

return 0 === $result;

Examples

0

#1 Let us check the iterability of different values

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)

Changelog

Since 4.9.6 Introduced.

is_iterable() code WP 6.7.1

return 0 === $result;
	}
endif;