note 58822 modified in function.is-array by danbrown

From: Date: Sat, 27 Dec 2008 16:49:35 +0000
Subject: note 58822 modified in function.is-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-148566@lists.php.net to get a copy of this message
this is my attempt at writing a function that would check for a multi dimentional array. where $dim is the number of dimentions you are checking for and $array is of course the variable that is being check. i dont know if there's a better way out there, but this is what i do. <?php function is_multi_array($array,$dim) { if(($dim==1)&&(is_array($array))) { return 1; } foreach($array as $level2) { if(is_multi_array($level2,$dim-1)) { return 1; } } return 0; } ?> --was-- this is my attempt at writing a function that would check for a multi dimentional array. where $dim is the number of dimentions you are checking for and $array is of course the variable that is being check. i dont know if there's a better way out there, but this is what i do. function is_multi_array($array,$dim) { if(($dim==1)&&(is_array($array))) { return 1; } foreach($array as $level2) { if(is_multi_array($level2,$dim-1)) { return 1; } } return 0; } http://php.net/manual/en/function.is-array.php

« previous php.notes (#148566) next »