php sort() on array produces wrong result

后端 未结 3 1010
灰色年华
灰色年华 2020-12-12 03:41

I want to sort an array that looks like this (to numerical order instead of 1, 10, 11):

Array ( [0] => 1.jpg [1] => 10.jpg [2] => 11.jpg [3] => 1         


        
3条回答
  •  一个人的身影
    2020-12-12 04:13

    sort() sorts the array in-place. Don't re-assign it.

    Correct:

    sort($this->pageLinks);
    

    Incorrect:

    $this->pageLinks = sort($this->pageLinks);
    

提交回复
热议问题