Checking if array is multidimensional or not?

后端 未结 25 3473
醉话见心
醉话见心 2020-11-28 01:41
  1. What is the most efficient way to check if an array is a flat array of primitive values or if it is a multidimensional array?
25条回答
  •  無奈伤痛
    2020-11-28 02:48

    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;
    }
    

提交回复
热议问题