PHP is_array() Function

❮ PHP Variable Handling Reference

Example

Check whether a variable is an array or not:

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

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

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

$d = "red, green, blue";
echo "d is " . is_array($d) . "<br>";
?>
Try it Yourself »

Definition and Usage

The is_array() function checks whether a variable is an array or not.

This function returns true (1) if the variable is an array, otherwise it returns false/nothing.


Syntax

is_array(variable);

Parameter Values

Parameter Description
variable Required. Specifies the variable to check

Technical Details

Return Value: TRUE if variable is an array, FALSE otherwise
Return Type: Boolean
PHP Version: 4.0+

❮ PHP Variable Handling Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.