Laravel排序数组自定义从querybuilder的结果



我从querybuilder得到了一个结果,我想要的是想要修改数组的排列。

我首先得到的是这个

{
"outsourcer": "NS&C㈱",
"manager_name": "安楽",
"worker_name": "吉田邦広",
"sesnum1": "MS-JAN-",
"sesnum2": 1,
"start": "2021-10-29",
"work": "TEST作業1",
"cost": 765000,
"worktime_l": "140",
"worktime_h": "180",
"cost_add": 1000,
"cost_trip": "7000",
"cost_trip_terms": "泊数換算",
"cost_midnight": 3000,
"cost_reduced": 0,
"end_date": "2022-03-31",
"end": "2022-03-31",
"quarter": "年度2022 1Q",
"reserve1": "",
"reserve2": "",
"working_period": "6か月"
},

我要做的是

{
"outsourcer": "NS&C㈱",
"manager_name": "安楽",
"worker_name": "吉田邦広",
"sesnum1": "MS-JAN-",
"sesnum2": 1,
"start": "2021-10-29",
"end": "2022-03-31", //transfered
"work": "TEST作業1",
"quarter": "年度2022 1Q", //transfered
"working_period": "6か月" //transfered
"reserve1": "", //transfered
"cost": 765000,
"worktime_l": "140",
"worktime_h": "180",
"cost_add": 1000,
"cost_trip": "7000",
"cost_trip_terms": "泊数換算",
"cost_midnight": 3000,
"cost_reduced": 0,
"reserve2": "",
"end_date": "2022-03-31", //transfered
},

我怎样才能实现它?我需要一个自定义函数吗?提前谢谢。

在PHP中,以下两个数组是等价的:

[
'key1' => 'value1',
'key2' => 'value2',
]
[
'key2' => 'value2',
'key1' => 'value1',
]

以字符串为键的数组没有排序顺序。

相关内容

  • 没有找到相关文章

最新更新