我有以下数组
Array
(
[0] => Array
(
[id_scheduled_work] => 238
[id_schedule_hours] => 1
[id_truck] => 1
[id_scheduled_work_details] => 209
[work_order] => Z20160807211621
)
[1] => Array
(
[id_scheduled_work] => 239
[id_schedule_hours] => 2
[id_truck] => 1
[work_order] => Z20160807211621
)
[2] => Array
(
[id_scheduled_work] => 240
[id_schedule_hours] => 1
[id_truck] => 1
[id_scheduled_work_details] => 209
[work_order] => A20160807211621
)
[3] => Array
(
[id_scheduled_work] => 245
[id_schedule_hours] => 2
[id_truck] => 1
[work_order] => A20160807211621
)
)
所以我想通过work_order编号删除重复的entires,所以我的最终数组应该是,我还需要重置密钥,以便它们变为0 1 ...
Array
(
[0] => Array
(
[id_scheduled_work] => 238
[id_schedule_hours] => 1
[id_truck] => 1
[id_scheduled_work_details] => 209
[work_order] => Z20160807211621
)
[1] => Array
(
[id_scheduled_work] => 240
[id_schedule_hours] => 1
[id_truck] => 1
[id_scheduled_work_details] => 209
[work_order] => A20160807211621
)
)
答案 0 :(得分:1)
$key = array_column(array, 'work_order');
$result = array_combine($keys, array);
试试吧