Array headaches

From: Date: Fri, 04 Aug 2000 18:35:20 +0000
Subject: Array headaches
Groups: php.general 
Request: Send a blank email to php-general+get-10175@lists.php.net to get a copy of this message
Hi can someone recommend a good resource for figuring out the sorting/displaying of multi-dimensional arrays? I've been @ this all day and I've got no closer to figuring it out the stage I'm @ now is: =>select child,parent,name from table build up this array => $cat_matrix[parent][child] = name i.e. $cat_matrix[0][1] = "Top Level"; $cat_matrix[0][2] = "Top Level 2"; $cat_matrix[0][3] = "Top Level 3"; $cat_matrix[1][4] = "Top Level - Sub1"; $cat_matrix[1][5] = "Top Level - Sub2"; $cat_matrix[2][6] = "Top Level 2 - Sub1"; $cat_matrix[2][7] = "Top Level 2 - Sub2"; $cat_matrix[3][8] = "Top Level 3 - Sub1"; $cat_matrix[7][9] = "Top Level 2 - Sub2 - SubSub1"; $cat_matrix[9][10] = "Top Level 2 - Sub2 - SubSub1 - subsubsub1"; etc......... and I want to end up with a threaded layout on the screen Top Level ==Top Level - Sub1 ==Top Level - Sub2 Top Level 2 ==Top Level 2 - Sub1 ==Top Level 2 - Sub2 ====Top Level 2 - Sub2 - SubSub1 ======Top Level 2 - Sub2 - SubSub1 - subsubsub1 Top Level 3 ==Top Level 3 - Sub1 and it is doing my poor head in, now it's an interesting excersise, but I'm at the stage where I need some input. Syntax is not an issue here, I've used arrays a million times before, it's purely the logic that I'm falling down on has anyone come across a decent code example that might give me the flash of inspiration that I need? tia Bealers

« previous php.general (#10175) next »