Current Location: Home> Function Categories> is_array

is_array

Detect whether a variable is an array
Name:is_array
Category:Variable processing
Programming Language:php
One-line Description:Check if the variable is an array.

Definition and usage

is_array() function checks whether the variable is an array.

If the variable is an array, the function returns true (1), otherwise false/none (returns nothing).

Example

Check if the variable is an array:

 <?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

grammar

 is_array ( variable ) ;
parameter describe
variable Required. Specifies the variable to check.
Similar Functions