使用键值在php中对多维数组进行排序

阿伦

我想使用php对下面的数组进行排序。该数组应按服务[0] [1]的值排序。

Array
(
[Services] => Array
    (
        [0] => Travel & Hotels  ~72
        [1] => Automotive~119
        [3] => Professional Services~71
        [4] => Home Services~70
        [6] => IT Services & Computer Repair~83
        [8] => Health and Medical~69
    )

[Restaurants] => Array
    (
        [0] => American / Eclectic~2
        [1] => Cafe~11
        [2] => Desserts & Bakery~111
    )

[Shopping] => Array
    (
        [0] => Office Equipment~103
        [3] => Department Stores~91
        [15] => Cosmetics & Beauty Supply~90
        [16] => Musical Instruments & Teachers~102
        [17] => Food~87
    )

[Entertainment] => Array
    (
        [0] => Bars/Pubs~48
    )

[Travel] => Array
    (
        [0] => Hotels~129
    )
)
帕特里克·Q

这样做应该很简单(假设$attractionArray是上面给出的外部数组):

foreach($attractionsArray as $key => $innerArray)
{
    sort($innerArray, SORT_STRING);
    $attractionArray[$key] = $innerArray;
}

看到它在这里行动

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章