note 66806 deleted from function.is-array by tularis

From: Date: Sun, 09 Oct 2011 09:26:25 +0000
Subject: note 66806 deleted from function.is-array by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183739@lists.php.net to get a copy of this message
Note Submitter: jupiter at nospam dot com ---- Will check a Multi-Dimentional Array to any specified level. This is a fix to 11/16/05 submission, which would break since you must supply a foreach with an array. Beware recursive functions shouldn't go over 100 deep or could break the memory stack on server. <?php // checks for multiarray to defined depth level recursively function isDeepMultiArray($multiarray, $level = 2) { // default is simple multi-array if (is_array($multiarray)) { // confirms array if ($level == 1) { // is array only 1 level deep, hence not multiarray return true; } // end conditional foreach ($multiarray as $array) { // goes one level deeper if (isDeepMultiArray($array, $level - 1)) { // check subarray return true; } // end recursive function } // end loop } else { // not an array at specified level return false; } } ?> BTW my notation is consistent with the PEAR manual on coding standards, which is what php.net says to follow. I hope a function like this gets included in PHP6.

« previous php.notes (#183739) next »