tree structure, Multi-dimensional Array
Posted: Mon May 24, 2010 3:15 pm
Hi,
I'v got a complete mind block and am looking for a pointer.
I am using the 'Nested Set Model Data' to store a directory tree structure in my database.
I have got as far as being able to put it into an assosiative array Name and Depth of each node .
and also have been able to put this into a Multi-dimensional Arrays.
I would like to convert this into a simple text output like:
The bit I just cannot work out is how do you find the parent node of a Multi-dimensional Array so I can create the a line like: portable_electronics.add(mp3_players);
Kind regards
Stephen
I'v got a complete mind block and am looking for a pointer.
I am using the 'Nested Set Model Data' to store a directory tree structure in my database.
I have got as far as being able to put it into an assosiative array Name and Depth of each node .
Code: Select all
Name -- Portable Electronics
depth -- 1
Name -- Mp3 Players
depth -- 2
Name -- Flash
depth -- 3
Name -- CD Player
depth -- 2
Code: Select all
array(5) {
["Name"]=>
string(20) "Portable Electronics"
["depth"]=>
string(1) "1"
[7]=>
array(3) {
["Name"]=>
string(11) "Mp3 Players"
["depth"]=>
string(1) "2"
[8]=>
array(2) {
["Name"]=>
string(5) "Flash"
["depth"]=>
string(1) "3"
}
}
[9]=>
array(2) {
["Name"]=>
string(9) "CD Player"
["depth"]=>
string(1) "2"
}
[10]=>
array(2) {
["Name"]=>
string(5) "Radio"
["depth"]=>
string(1) "2"
}
}
Code: Select all
var portable_electronics = new WebFXTreeItem('Portable Electronics');
var mp3_players = new WebFXTreeItem('Mp3 Players');
var cd_player = new WebFXTreeItem('CD Player');
var radio = new WebFXTreeItem('Radio');
var flash = new WebFXTreeItem('Flash');
portable_electronics.add(mp3_players);
mp3_players.add(flash);
portable_electronics.add(cd_player);
portable_electronics.add(radio);
Kind regards
Stephen