note 66806 added to function.is-array

From: Date: Tue, 30 May 2006 02:50:22 +0000
Subject: note 66806 added to function.is-array
Groups: php.notes 
Request: Send a blank email to php-notes+get-112520@lists.php.net to get a copy of this message
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. ---- Server IP: 66.163.161.117 Probable Submitter: 68.104.56.193 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.is-array.php Edit -- http://master.php.net/note/edit/66806 Del: integrated -- http://master.php.net/note/delete/66806/integrated Del: useless -- http://master.php.net/note/delete/66806/useless Del: bad code -- http://master.php.net/note/delete/66806/bad+code Del: spam -- http://master.php.net/note/delete/66806/spam Del: non-english -- http://master.php.net/note/delete/66806/non-english Del: in docs -- http://master.php.net/note/delete/66806/in+docs Del: other reasons-- http://master.php.net/note/delete/66806 Reject -- http://master.php.net/note/reject/66806 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#112520) next »