按对象数组

时间:2017-02-14 15:19:08

标签: php arrays sorting object

如何按林名或树高例法对此数组进行排序:
森林名称是"森林湖"和#34;中央森林"所以城市将是 按照他们的森林排序,所以City Object" Pogradec"将是第一个而不是地拉那",
根据树木的高度,它们应该在森林内进行分类,并且还要 树木最高的城市应该是第一位的。 :

Array
(
    [0] => City Object
        (
            [name] => Tirana
            [forests] => Array
                (
                    [0] => Forest Object
                        (
                            [name] => Lake Forest
                            [details] => Array
                                (
                                    [0] => Tree Object
                                        (
                                            [name] => Black Ash
                                            [height] => 5                                   
                                        )

                                    [0] => Tree Object
                                        (
                                            [name] => White Ash
                                            [height] => 7

                                         )
                                )   
                        )   
                )    
        )

    [1] => City Object
        (
            [name] => Pogradec
            [forests] => Array
                (
                    [0] => Forest Object
                        (
                            [name] => Central Forest
                            [details] => Array
                                (
                                    [0] => Tree Object
                                        (
                                            [name] => Black Ash
                                            [height] => 13
                                        )

                                    [1] => Tree Object
                                        (
                                            [name] =>White Ash
                                            [height] => 23
                                        )
                                )
                        )
                )
        )
)

0 个答案:

没有答案