• PHP Video Tutorials

PHP - is_iterable() Function


Advertisements

Definition and Usage

The function is_iterable checks whether the contents of a variable is an iterable value.

Syntax

bool is_iterable ( mixed $value )

Parameters

Sr.No Parameter & Description
1

value

The value to check

Return Values

This function returns true if value is iterable, false otherwise. This function verifies that the contents of a variable is accepted by the iterable pseudo-type, i.e. that it is either an array or an object implementing Traversable

Dependencies

PHP 7.1 and above

Example

Following example demonstrates return values with different types of variables −

<?php
   //array
   $a = [4, 5, 6];
   echo "a is "; var_dump(is_iterable($a)); echo "<br>";

   //array object
   $b = new ArrayIterator([1, 2, 3]);
   echo "b is "; var_dump(is_iterable($b)); echo "<br>";

   //int
   $c = 3;
   echo "c is "; var_dump(is_iterable($c)); echo "<br>";

   //object
   $d = new stdClass();
   echo "d is "; var_dump(is_iterable($d)); echo "<br>";
?>

Output

This will produce following result −

a is bool(true)
b is bool(true)
c is bool(false)
d is bool(false)
php_variable_handling_functions.htm

Useful Video Courses


Video

PHP Online Training

45 Lectures 9 hours

Malhar Lathkar

Video

Become PHP Facebook Developer: Password-Less Authentication

34 Lectures 4 hours

Syed Raza

Video

Ultimate PHP & MySQL Web Development Course & OOP Coding

84 Lectures 5.5 hours

Frahaan Hussain

Video

Learn PHP from Scratch

17 Lectures 1 hours

Nivedita Jain

Video

E Commerce Website Development In PHP With PDO

100 Lectures 34 hours

Azaz Patel

Video

PHP in Telugu

43 Lectures 5.5 hours

Vijay Kumar Parvatha Reddy

Advertisements