laravel sort an array by date

后端 未结 4 592
难免孤独
难免孤独 2021-01-06 02:17

hello friends I have an array that looks like this:

array:3 [▼
  0 => array:6 [▼
    \"date\" => \"2016-05-31 15:08:33\"
    0 => \"31 May 16\"
             


        
4条回答
  •  春和景丽
    2021-01-06 02:52

    You can convert to a collection, call the sortBy() and the convert back to an array all on one line.

    $sortedArr = collect($array)->sortBy('date')->all();
    

提交回复
热议问题