Try as follows
if (count($arrayList) != count($arrayList, COUNT_RECURSIVE))
{
echo 'arrayList is multidimensional';
}else{
echo 'arrayList is no multidimensional';
}
Even this works
is_array(current($array));
If false its a single dimension array if true its a multi dimension array.
current will give you the first element of your array and check if the first element is an array or not by is_array function.
For PHP 4.2.0 or newer:
function is_multi($array) {
return (count($array) != count($array, 1));
}
Its as simple as
$isMulti = !empty(array_filter($array, function($e) {
return is_array($e);
}));
if($array[0]){
//enter your code
}
All great answers... here's my three lines that I'm always using
function isMultiArray($a){
foreach($a as $v) if(is_array($v)) return TRUE;
return FALSE;
}