NYCPHP Meetup

NYPHP.org

[nycphp-talk] Flattening a Tree

justin justin at justinhileman.info
Tue Feb 24 08:57:35 EST 2009


On Mon, Feb 23, 2009 at 11:12 PM, Ajai Khattri <ajai at bitblit.net> wrote:
> On Mon, 23 Feb 2009, Tim Lieberman wrote:
>
>> Yup, your standard depth-first tree traversal.
>
> But in order to build a flat array, I'd have to pass that by reference
> into my recursive function so it can append the each node right?
>

You could use array_merge() on the way out. Do you want to preserve
keys, or can you handle getting back a numerically indexed array?

-- 
justin
http://justinhileman.com



More information about the talk mailing list