PHP按属性值对多维对象进行排序

时间:2013-03-21 12:52:52

标签: php

经过数小时的研究,我决定问这个问题,bcoz到目前为止还没有找到解决方案。 我需要按属性值对多维对象进行排序,对象是多维json的json_decode()的结果,所以我需要按order属性对以下对象进行排序:

    stdClass Object
(
    [main] => stdClass Object
        (
            [order] => 1
            [size] => 100
            [child] => stdClass Object
                (
                    [c1] => stdClass Object
                        (
                            [order] => 2 // must be second item
                            [size] => 100
                            [child] => stdClass Object
                                (
                                    [d1] => stdClass Object
                                        (
                                            [order] => 1
                                            [size] => 100
                                        )
                                )
                        )
                    [c2] => stdClass Object
                        (
                            [order] => 1, // must be first item
                            [size] => 100,
                            [child] => stdClass Object
                                (
                                    [d2] => stdClass Object
                                        (
                                            [order] => 1
                                            [size] => 100
                                        )
                                )                           
                        )

谢谢!

0 个答案:

没有答案