You are here: Using a recursive ArrayIterator « PHP « IT news, forums, messages
Using a recursive ArrayIterator

Posted by V Kam on 10/04/05 11:07

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация