tags:

views:

48

answers:

1

Good day!

I'm Googling it second day already, but haven't found anything relevant, so that's my last chance before I'll start to reinvent the wheel :)

In ASP.NET I use generic tree classes, something like this: http://www.codeproject.com/KB/recipes/phSharpTree.aspx

Of course PHP lacks generics :), but I just want a class which give me ability to store my object in it and iterate through nodes using PHP5 iterators (from root to children, from selected node to root etc).

Thanks in advance!

+1  A: 

PHP does support certain generics via the SPL (Standard PHP Library) that's been built in since PHP 5.0. There are also a wide variety of iterators available that might well be ideal. (Full list here.)

That said, the documentation is currently somewhat lacking in places, so you might have to do quite a bit of legwork yourself.

middaparka
As far as I understand, SPL just provides interfaces to implement Iterators, but I haven't found any classes that uses this approach...May be I'm missing something?
artvolk
Not sure - there's some additional information at http://www.php.net/~helly/php/ext/spl/ and a good tutorial at http://www.phpro.org/tutorials/Introduction-to-SPL.html that I'm currently wading though. :-)
middaparka
Thanks for the links, I'm already digging into it. It seems I have to impelement class that I want using SPL from ground up... :(
artvolk
Looks like it from what I can surmise as well. :-(
middaparka