note 75677 added to ref.array
| From: | webdev at svbeatrix dot com | Date: | Mon, 11 Jun 2007 16:06:37 +0000 |
| Subject: | note 75677 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127394@lists.php.net to get a copy of this message | ||
Bugs happen, but how can people post functions that WON'T EVEN COMPILE! I truly detest finding
a cool code snippet or function and then having to debug them. Sorry for the rant, but I have
experienced this scenario a number of times. TEST YOUR CODE, THEN POST!
Here is a revised and corrected previously posted function ArrayDepth, which had 3 bugs and yes,
would not compile.
function ArrayDepth($Array,$DepthCount=-1) {
// Find maximum depth of an array
// Usage: int ArrayDepth( array $array )
// returns integer with max depth
// if Array is a string or an empty array it will return 0
$DepthArray=array(0);
$DepthCount++;
$Depth = 0;
if (is_array($Array))
foreach ($Array as $Key => $Value) {
$DepthArray[]=ArrayDepth($Value,$DepthCount);
}
else
return $DepthCount;
return max($DepthCount,max($DepthArray));
}
----
Server IP: 64.71.164.2
Probable Submitter: 66.146.171.90
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- https://master.php.net/note/edit/75677
Del: integrated -- https://master.php.net/note/delete/75677/integrated
Del: useless -- https://master.php.net/note/delete/75677/useless
Del: bad code -- https://master.php.net/note/delete/75677/bad+code
Del: spam -- https://master.php.net/note/delete/75677/spam
Del: non-english -- https://master.php.net/note/delete/75677/non-english
Del: in docs -- https://master.php.net/note/delete/75677/in+docs
Del: other reasons-- https://master.php.net/note/delete/75677
Reject -- https://master.php.net/note/reject/75677
Search -- https://master.php.net/manage/user-notes.php