PHP Tip: Check If Array Is Multidimensional
Here's a handy little snippet that you can use to determine if the array you are about to work with is multidimensional or now.
if (count($array) == count($array, COUNT_RECURSIVE)) { /* not multidimentional */ } else { /* multidimensional */ }
By default, count() just counts the elements in the first level of the array. When you specify COUNT_RECURSIVE option, it loops through counting everything. If both match, it isn't multidimensional.














