News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Kevin van Zonneveld's Blog:
Convert anything to Tree Structures in PHP
October 09, 2007 @ 16:38:00

Kevin van Zonneveld has posted a new example today of how to convert anything into a tree structure with PHP:

With a function on this site: explodeTree(), you can explode any single-dimensional array into a full blown tree. The function uses a user-specified delimiter found in the keys of the original array to separate nodes and determine hierarchy.

Sample: with 3 lines of code you could have a full directory hierarchy in a multi-dimensional array if you specify the delimiter to be a '/' (slash).

Not only is the code included to make the tree from the data, but an example block of code showing how to use the result.

0 comments voice your opinion now!
tree structure convert tutorial example usage tree structure convert tutorial example usage


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Playing with the new PHP5.4 features

Vance Lucas' Blog: Practical Uses for PHP 5.3 Closures

Mike Willbanks' Blog: Zend Framework Cache Backend Libmemcached + Session Cache

Brandon Savage: What’s in your Composer file?

Chris Hartjes' Blog: Tutorial: How to create a thread in vBulletin with a script


Community Events





Don't see your event here?
Let us know!


conference podcast list interview community introduction zendserver voicesoftheelephpant deployment language series release tips threedevsandamaybe symfony laravel api code framework bugfix

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework