How to get tree structure into an array?

From: Date: Tue, 25 Feb 2003 10:16:02 +0000
Subject: How to get tree structure into an array?
Groups: php.general 
Request: Send a blank email to php-general+get-137052@lists.php.net to get a copy of this message
Hi all! i have to solve one problem, but i have no idea how to make this. I have got a tree strucutre in mysql table, id - parent - name. I need make function, which return array which will contains a strucutre of this tree-menu, table example: ID Parent Name ------ ------ ---------------------- 1 0 Components 4 1 Main boards 5 1 HD 7 5 IDE 8 5 SCSI and result: $array = Array( "id" => "1", "name" => "Components", "sub" => array( "id" => "4", "name" => "Mainboards", "sub" => no_array (no sub pages)), array( "id" => "5", "name" => "HD", "sub" => Array( "id" => "7", "name" => "IDE", "sub" => no_array (no sub pages)), Array( "id" => "8", "name" => "SCSI", "sub" => no_array (no sub pages)) ) ); an so on, source table has got about 300 items, so i need function which make an array for next work with this tree structure. thanks a lot for some help! jiri.nemec at menea.cz http://www.menea.cz ICQ: 114651500

« previous php.general (#137052) next »