按键值从多维数组中删除重复数组



我有以下数组

 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号删除重复的实体,所以我的最终数组应该是,我还需要重置键,使它们进入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
    )
)
$key = array_column(array, 'work_order');
$result = array_combine($keys, array);

试试

相关内容

  • 没有找到相关文章

最新更新