PHP按升序数组值

时间:2016-03-27 09:01:21

标签: php

以下是我的数组的部分内容

我尝试使用下面的功能对其进行排序,按页面升序排序 然而,它似乎隆隆作响,页面没有处于增量状态。

我不确定我的排序比较器功能(cmp)

有什么问题
function cmp($a, $b) {
    return $a['page'] - $b['page'];
}


usort($chapter_result_array,"cmp");
$chapter_result_array = array_reverse($chapter_result_array);



[11] => Array
    (
        [link] => https://www.mywebsite.com/projects/funny-story/chapter-8-1.1046/
        [page] => 8.1
    )

[12] => Array
    (
        [link] => https://www.mywebsite.com/projects/funny-story/chapter-8-2.1085/
        [page] => 8.2
    )

[13] => Array
    (
        [link] => https://www.mywebsite.com/projects/funny-story/chapter-9-1.1114/
        [page] => 9.1
    )

[14] => Array
    (
        [link] => https://www.mywebsite.com/projects/funny-story/chapter-6-1.890/
        [page] => 6.1
    )

[15] => Array
    (
        [link] => https://www.mywebsite.com/projects/funny-story/chapter-6-2.995/
        [page] => 6.2
    )

[16] => Array
    (
        [link] => https://www.mywebsite.com/projects/funny-story/chapter-7-1.1020/
        [page] => 7.1
    )

[17] => Array
    (
        [link] => https://www.mywebsite.com/projects/funny-story/chapter-5-1.855/
        [page] => 5.1
    )

1 个答案:

答案 0 :(得分:0)

我猜这些网页不是addChild(new devTextMC()); 值,而是更像“版本字符串”,因此您应该与版本比较进行比较:Compare two version strings in PHP

它将返回-1,0或1,如var instance:devTextMC = new devTextMC(); addChild(instance); instance.x = 100; instance.y = 50; 意图使用。

相关问题