is_iterable()WP 4.9.6

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

true|false. True if $var is iterable, false otherwise.

Usage

is_iterable( $var );
$var(mixed) (required)
The value to check.

Changelog

Since 4.9.6 Introduced.

Code of is_iterable() WP 5.9.3

function is_iterable( $var ) {
	return ( is_array( $var ) || $var instanceof Traversable );
}