Re: Array headaches
| From: | Bill Zeller | Date: | Fri, 04 Aug 2000 21:30:45 +0000 |
| Subject: | Re: Array headaches | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-10196@lists.php.net to get a copy of this message | ||
Hi,
I took the pleasure of writing up a little function
that should do the trick. When I ran it, it printed
this:
-----------
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
--------------------
Script is attached.
Best Regards,
Bill Zeller
--- Darren Beale <bealers@back-end.org> wrote:
> 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
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-general-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/