Welcome Guest, Not a member yet? Register   Sign In
More recursive madness
#5

[eluser]skunkbad[/eluser]
Probably the best way to approach what I am trying to do is simply show the result array, and then the processed/sorted array.

This is the result array before sorting:

Code:
Array
(
    [0] => Array
        (
            [category_id] => 1
            [category_name] => Examples
            [parent_id] => 0
        )

    [1] => Array
        (
            [category_id] => 6
            [category_name] => Something
            [parent_id] => 0
        )

    [2] => Array
        (
            [category_id] => 2
            [category_name] => Widgets
            [parent_id] => 1
        )

    [3] => Array
        (
            [category_id] => 3
            [category_name] => Little
            [parent_id] => 1
        )

    [4] => Array
        (
            [category_id] => 7
            [category_name] => Yaknow
            [parent_id] => 1
        )

    [5] => Array
        (
            [category_id] => 4
            [category_name] => Hardcore
            [parent_id] => 2
        )

    [6] => Array
        (
            [category_id] => 8
            [category_name] => Whatever
            [parent_id] => 2
        )

    [7] => Array
        (
            [category_id] => 11
            [category_name] => Hardcore
            [parent_id] => 3
        )

)

This is the array after sorting:

Code:
Array
(
    [Examples] => Array
        (
            [category_id] => 1
            [sub] => Array
                (
                    [Widgets] => Array
                        (
                            [category_id] => 2
                            [sub] => Array
                                (
                                    [Hardcore] => Array
                                        (
                                            [category_id] => 4
                                        )

                                    [Whatever] => Array
                                        (
                                            [category_id] => 8
                                        )

                                )

                        )

                    [Little] => Array
                        (
                            [category_id] => 3
                            [sub] => Array
                                (
                                    [Hardcore] => Array
                                        (
                                            [category_id] => 11
                                        )

                                )

                        )

                    [Yaknow] => Array
                        (
                            [category_id] => 7
                        )

                )

        )

    [Something] => Array
        (
            [category_id] => 6
        )

)

This array goes into the view where the category menu is built with yet another recursive function. I am probably just overworking this....


Messages In This Thread
More recursive madness - by El Forum - 04-20-2010, 06:11 PM
More recursive madness - by El Forum - 04-20-2010, 07:06 PM
More recursive madness - by El Forum - 04-20-2010, 07:09 PM
More recursive madness - by El Forum - 04-20-2010, 08:55 PM
More recursive madness - by El Forum - 04-21-2010, 03:06 AM
More recursive madness - by El Forum - 04-21-2010, 09:11 AM
More recursive madness - by El Forum - 04-21-2010, 02:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB