Sometimes I need to judge the dimensions of the array. I checked online and found many things similar to http://www.poluoluo.com/jzxy/201306/215088.html. This way of writing is confusing and I don’t understand what it means. Here's what I wrote:
privatestaticfunctionarray_depth($array) {if(!is_array($array)) return0; $max_depth = 1; foreach ($arrayas$value) { if (is_array($value)) { $depth = array_depth($value) + 1; if ($depth > $max_depth) { $max_depth = $depth; } } } return$max_depth; }
The above introduces the encapsulated function of judging the dimension of array Array in PHP, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.