关于一个多级菜单(大于2级)的PHP数组问题

babyprogramer 发布于 2014/03/26 15:59
阅读 317
收藏 0

我已经获得了如下数组

Array
(
    [0] => Array
        (
            [p_id] => 0
            [child] => Array
                (
                    [0] => Array
                        (
                            [p_id] => 1
                            [p_title] => Home                            
                            [p_parent_id] => 0                            
                        )

                    [1] => Array
                        (
                            [p_id] => 2
                            [p_title] => Products                            
                            [p_parent_id] => 0                           
                        )

                    [2] => Array
                        (
                            [p_id] => 3
                            [p_title] => Innovations                            
                            [p_parent_id] => 0                           
                        )

                )

        )

    [1] => Array
        (
            [p_id] => 1
            [child] => Array
                (
                    [0] => Array
                        (
                            [p_id] => 61
                            [p_title] => banner                            
                            [p_parent_id] => 1                            
                        )

                    [1] => Array
                        (
                            [p_id] => 62
                            [p_title] => Products                            
                            [p_parent_id] => 1                            
                        )

                    [2] => Array
                        (
                            [p_id] => 63
                            [p_title] => About Us                            
                            [p_parent_id] => 1                            
                        )
                )

        )

    [2] => Array
        (
            [p_id] => 2
            [child] => Array
                (
                    [0] => Array
                        (
                            [p_id] => 9
                            [p_title] => Underwater Engineering                            
                            [p_parent_id] => 2                            
                        )

                    [1] => Array
                        (
                            [p_id] => 10
                            [p_title] => Pipeline Container                            
                            [p_parent_id] => 2                            
                        )

                    [2] => Array
                        (
                            [p_id] => 11
                            [p_title] => Drilling Platform                            
                            [p_parent_id] => 2                            
                        )

                    [3] => Array
                        (
                            [p_id] => 12
                            [p_title] => Steel Structure                            
                            [p_parent_id] => 2                           
                        )

                    [4] => Array
                        (
                            [p_id] => 13
                            [p_title] => Jack-up                            
                            [p_parent_id] => 2                           
                        )

                )

        )

   
    [9] => Array
        (
            [p_id] => 9
            [child] => Array
                (
                    [0] => Array
                        (
                            [p_id] => 14
                            [p_title] => Trencher                            
                            [p_parent_id] => 9                            
                        )

                    [1] => Array
                        (
                            [p_id] => 15
                            [p_title] => Robot                            
                            [p_parent_id] => 9                            
                        )

                    [2] => Array
                        (
                            [p_id] => 16
                            [p_title] => Diving Equipment                            
                            [p_parent_id] => 9                            
                        )

                )

        )


    

    [16] => Array
        (
            [p_id] => 22
            [child] => Array
                (
                    [0] => Array
                        (
                            [p_id] => 27
                            [p_title] => Chemical Engineering                            
                            [p_parent_id] => 22                           
                        )

                    [1] => Array
                        (
                            [p_id] => 28
                            [p_title] => Methyl Alcohol                           
                            [p_parent_id] => 22                           
                        )

                    [2] => Array
                        (
                            [p_id] => 29
                            [p_title] => Natural Gas                            
                            [p_parent_id] => 22                             
                        )

                    [3] => Array
                        (
                            [p_id] => 30
                            [p_title] => Chemical Fertilizer                            
                            [p_parent_id] => 22                           
                        )

                    [4] => Array
                        (
                            [p_id] => 31
                            [p_title] => Evaporator                            
                            [p_parent_id] => 22                           
                        )

                    [5] => Array
                        (
                            [p_id] => 32
                            [p_title] => Special Cans                            
                            [p_parent_id] => 22                           
                        )

                )

        )
 

)

请问如何将数组按照ID进行合并,要分级的

加载中
返回顶部
顶部