我有这样的两个数组.
$array5 = json_decode('[{"time":"12:08 PM","md5":1201},{"time":"01:00 PM","md5":1121},{"day":"03:03 PM","md5":1401},{"time":"03:36 PM","md5":1334}]
',true);
$array6 = json_decode('[{"time":"12:08 PM","ips":20},{"time":"01:00 PM","ips":10},{"time":"03:02 PM","ips":12},{"time":"03:36 PM","ips":11}]', true);
使用array_merge_recursive的组合数组是:
[{"time":"12:08 PM","url":1201,"ips":20},{"time":"01:00 PM","url":1121,"ips":10},{"time":"03:03 PM","url":1401},{"time":"03:36 PM","url":1334,"ips":11},{"time":"03:02 PM","ips":12}]
现在我想根据时间对这个数组进行排序.是否有可能根据时间对这个数组进行排序?
解决方法:
$array = array_values(array_sort($array, function ($value) {
return new Carbon($value['time']);
}));
标签:php,laravel
来源: https://codeday.me/bug/20190727/1551341.html