note 55044 added to function.each

From: Date: Sat, 23 Jul 2005 12:17:20 +0000
Subject: note 55044 added to function.each
Groups: php.notes 
Request: Send a blank email to php-notes+get-92336@lists.php.net to get a copy of this message
If you want to display the hole structure (tree) of your array, then you can use this recursive solution. <?PHP $tree= ""; array_tree($your_array); echo $tree; // Recursive Function function array_tree($array, $index=0){ global $tree; $space=""; for ($i=0;$i<$index;$i++){ $space .= " "; } if(gettype($array)=="array"){ $index++; while (list ($x, $tmp) = each ($array)){ $tree .= $space."$x => $tmp\n"; array_tree($tmp, $index); } } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.each.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55044 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55044&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55044&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55044&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55044&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55044&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55044&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55044&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92336) next »