php method to determine the dimensionality of an array: first create a PHP sample file; then define a TestArray function; finally, traverse the foreach and "is_array" functions to determine the dimensionality of the array.
#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.
PHP checks whether the current array is a multi-dimensional array
/** * [TestArray 检测数组是一维还是二维] * @E-mial wuliqiang_aa@163.com * @TIME 2017-04-07 * @WEB http://blog.iinu.com.cn * @param [type] $array [数组] */ function TestArray($array){ foreach($array as $v){ if(is_array($v)){ $Int_Array = array('status'=>2,'return'=>'检测为二维数组'); }else{ $Int_Array = array('status'=>1,'return'=>'检测为一维数组'); } } return $Int_Array; }
[Recommended learning: "PHP Video Tutorial"]
The above is the detailed content of How to determine the dimensionality of an array in php. For more information, please follow other related articles on the PHP Chinese website!