首頁 >後端開發 >php教程 >排序.小弟我想下面的数组以cat_name来排序

排序.小弟我想下面的数组以cat_name来排序

WBOY
WBOY原創
2016-06-13 11:55:41985瀏覽

排序...我想下面的数组以cat_name来排序
Array
(
    [1] => Array
        (
            [cat_id] => 1
            [cat_name] => Other
        )

    [2827511014] => Array
        (
            [cat_id] => 2827511014
            [cat_name] => mobile phone housing
        )

    [2827513014] => Array
        (
            [cat_id] => 2827513014
            [cat_name] => mobile phone other accessories
        )

    [2827516014] => Array
        (
            [cat_id] => 2827516014
            [cat_name] => PC Accessories
        )

    [2827518014] => Array
        (
            [cat_id] => 2827518014
            [cat_name] => Electronics
        )

    [3089502014] => Array
        (
            [cat_id] => 3089502014
            [cat_name] => Jewelry Accessories
            [child] => Array
                (
                    [3089509014] => Array
                        (
                            [cat_id] => 3089509014
                            [cat_name] => Necklace
                        )

                    [3089510014] => Array
                        (
                            [cat_id] => 3089510014
                            [cat_name] => Earrings
                        )

                    [3158873014] => Array
                        (
                            [cat_id] => 3158873014
                            [cat_name] => headband
                        )

                )

        )

。。。。。。
------解决方案--------------------

$a = 你的数组;<br />foreach($a as $r) $b[] = $r['cat_name'];<br />array_multisort($b, $a);<br />

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn