我无法对这个对象数组进行排序。请帮助。我usort用于对数组进行排序。我也收到此错误:PHP 解析错误:第 7 行 /home/cg/root/128245/main.php 中的语法错误,意外的 '=>' (T_DOUBLE_ARROW),期待 ')'我需要按照我的班级的job_name属性的顺序对这个数组进行排序。<?php $gfg_array =Array( [0] => Array ( [status] => SUCCESS [duration] => 04:32:22 [date] => 13-Jun-2019 [start_stamp] => 02:29:32 [type] => implicit [job_name] => build-bbjsd ) [1] => Array ( [status] => SUCCESS [change_sets] => Array ( ) [job_id] => # 4156 [url] => http://www.html.com [duration] => 0:39:25 [test_script] => {"tc_results": [{"status": "pass", "testcase_time": "0:01:06"}]} [date] => 2019-06-13 [start_stamp] => 9:30:34 [type] => explicit [job_name] => json-dhj ) [2] => Array ( [status] => SUCCESS [duration] => [date] => [start_stamp] => [type] => implicit [job_name] => ci-ulp [3] => Array ( [status] => DISABLED [duration] => [date] => [start_stamp] => [type] => implicit [job_name] => build-c201-qemux86-64 ) [4] => Array ( [status] => SUCCESS [duration] => 04:30:30 [date] => 13-Jun-2019 [start_stamp] => 02:29:15 [type] => implicit [job_name] => build-fss-image-full-l200-qemux86-64 )
2 回答
米脂
TA贡献1836条经验 获得超3个赞
你可以试试这个功能。。
function multisortByKeyValue( $k, $arr ) {
$ids = array();
$index = 1;
foreach ( $arr as $key => $row ) {
$ids[ $key ] = intval( $row[ $k ] ) . '-' . $index . '-' . $key;
$index ++;
}
natsort( $ids );
$arr = array_merge( $ids, $arr );
return $arr;
}
```
- 2 回答
- 0 关注
- 230 浏览
添加回答
举报
0/150
提交
取消