note 51643 added to ref.array

From: Date: Wed, 06 Apr 2005 11:45:30 +0000
Subject: note 51643 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-87571@lists.php.net to get a copy of this message
How to count dimensions in multi-array. The last post which corrects an other fails in arrays that include an element that is not an array, an array, and other no array element because is setting always 1 when is not an array. Also, don't look every element inside an array. I put it inside a foreach and ask (when is not an array) if the previous return value is greater. Here is the code: function ContarDimensions($ArrayDonat) { foreach ($ArrayDonat as $Registre) { if (is_array($Registre)) { $return = ContarDimensions($Registre) + 1; } else { if ($return<=1) { $return = 1; } } } return $return; } Sorry my poor english. I'm new in PHP, so maybe it can be done better. ---- Manual Page -- http://www.php.net/manual/en/ref.array.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51643 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51643&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51643&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51643&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51643&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51643&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51643&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87571) next »