Using a recursive ArrayIterator

From: Date: Thu, 03 Feb 2005 15:46:45 +0000
Subject: Using a recursive ArrayIterator
Groups: php.general 
Request: Send a blank email to php-general+get-207996@lists.php.net to get a copy of this message
Hello all I need some assistance converting code to use the RecursiveIterator in PHP 5 SPL. I have the following function which scans through a nested array set and returns the path to all matches. <?php function arraySearchRecursive($needle, $haystack, $path="") { foreach($haystack as $key=>$value) { $path .= "$key/"; // unset the path once the end of the tree is reached if (is_array($value)) { arraySearchRecursive($needle, $value, $path); unset($path); } else { echo $path; } } } ?> I'm trying to convert this to use iterators as I believe that may be faster/more efficient. However I'm totally confused as to how to do it given the large number of interfaces/classes and lack of documentation. Could someone knowledgeable on the list help me get started? Ideally I'd like a framework/outline in pseudocode. Thanks! Kam __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail

« previous php.general (#207996) next »