The function is_array() is used to check whether a variable is an array or not.
bool is_array ( mixed $value )
Sr.No | Parameter & Description |
---|---|
1 |
value The variable being evaluated |
This function returns boolean value true if value is an array, otherwise returns false.
PHP 4 and above
Following example demonstrates use of is_array() function −
<?php $a = array('a', 'b', 'c'); echo 'a '.(is_array($a) ? 'Is an Array' : 'not an Array').'<br>'; $b = array("a"=>"1", "b"=>"2", "c"=>"3"); echo 'b '.(is_array($b) ? 'Is an Array' : 'not an Array').'<br>'; $c = 'this is a string'; echo 'c is '.(is_array($c) ? 'Is an Array' : 'not an Array').'<br>'; ?>
This will produce following result −
a Is an Array b Is an Array c is not an Array