Friday, 3 October 2014

is_array in PHP

is_array — Finds whether a variable is an array

Syntax: bool is_array ( mixed $var )
Finds whether the given variable is an array.
Parameters: 
var:The variable being evaluated.
Return Values:
Returns TRUE if var is an array, FALSE otherwise.
Example #1
<?php
$yes = array('this', 'is', 'an array');
echo is_array($yes) ? 'Array' : 'not an Array';
echo "\n";
$no = 'this is a string';
echo is_array($no) ? 'Array' : 'not an Array';
?>
Output:
Array
not an Array

0 comments:

Post a Comment