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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to