❮ PHP Variable Handling Reference
Check whether the contents of a variable is 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>";
?>
Try it Yourself »
The is_iterable() function checks whether the contents of a variable is an iterable value or not.
This function returns true (1) if the variable is iterable, otherwise it returns false/nothing.
is_iterable(
variable);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Return Value: | TRUE if variable is iterable, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 7.1+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!