note 11498 deleted from function.array-keys by jimw

From: Date: Fri, 14 Dec 2001 21:17:20 +0000
Subject: note 11498 deleted from function.array-keys by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22823@lists.php.net to get a copy of this message
This is the function to use if you want to recurse over an array of arrays: function recurse ($l_array, $l_level) { $l_keys = array_keys($l_array); foreach ($l_keys as $l_key) { if (is_array($l_array[$l_key])) { recurse($l_array[$l_key], $l_level + 1); } else { # do something with $l_array[$l_key], knowing $l_level } } } $array = array(7, 'w', 3, array(6, 5, array('x', 'y'), 1), array(11, 'z'), 10); recurse($array, 1);

« previous php.notes (#22823) next »