note 69237 added to ref.array
| From: | ob at babcom dot biz | Date: | Mon, 28 Aug 2006 11:23:02 +0000 |
| Subject: | note 69237 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116423@lists.php.net to get a copy of this message | ||
Here is a function to find out the maximum depth of a multidimensional array.
<?php
// return depth of given array
// if Array is a string ArrayDepth() will return 0
// usage: int ArrayDepth(array Array)
function ArrayDepth($Array,$DepthCount=-1,$DepthArray=array()) {
$DepthCount++;
if (is_array($Array))
foreach ($Array as $Key => $Value)
$DepthArray[]=ArrayDepth($Value,$DepthCount);
else
return $DepthCount;
foreach($DepthArray as $Value)
$Depth=$Value>$Depth?$Value:$Depth;
return $Depth;
}
?>
----
Server IP: 66.163.161.117
Probable Submitter: 84.185.247.44
----
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/ref.array.php
Edit -- https://master.php.net/note/edit/69237
Del: integrated -- https://master.php.net/note/delete/69237/integrated
Del: useless -- https://master.php.net/note/delete/69237/useless
Del: bad code -- https://master.php.net/note/delete/69237/bad+code
Del: spam -- https://master.php.net/note/delete/69237/spam
Del: non-english -- https://master.php.net/note/delete/69237/non-english
Del: in docs -- https://master.php.net/note/delete/69237/in+docs
Del: other reasons-- https://master.php.net/note/delete/69237
Reject -- https://master.php.net/note/reject/69237
Search -- https://master.php.net/manage/user-notes.php