php sort() on array produces wrong result

后端 未结 3 1009
灰色年华
灰色年华 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:16

    You should read the manual on sort(), you give it a reference for an array, and it'll work on it. No need to reassign it.

    sort($array);
    

    and not

    $array = sort($array);
    

提交回复
热议问题