PHP is_iterable() Function

PHP is_long() Function
PHP is_integer() Function

In this article, you will learn how to check if a variable contains iterable value or not in PHP. Iterable value in PHP is a value on which we can implement loop.

The is_iterable() function in PHP checks whether the contents of a variable are an iterable value or not. This function returns true (1) if the variable is iterable, otherwise it returns false/nothing.

what is the syntax of the IS_ITERABLE() function in php?

is_iterable(variable);
ParameterDescription
variableRequired. Specifies the variable to check
PHP is_iterable() method

examples of the IS_ITERABLE() function

Example 1. In this example, we check whether the contents of a variable are an iterable value or not.

<?php
$a = "Hello";
echo "a is " . is_iterable($a) . "<br>";

$b = array("red", "green", "blue");
echo "b is " . is_iterable($b) . "<br>";

$c = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
echo "c is " . is_iterable($c) . "<br>";

$d = [1, 2, 3];
echo "d is " . is_iterable($d) . "<br>";
?>
PHP is_long() Function
PHP is_integer() Function

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top