2

i have the following array

 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

    )

  )

So i want to remove duplicate entires by work_order number so my final array should be and i also need to reset the keys so that they go 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

    )

)
2

1 Answer 1

1
$key = array_column(array, 'work_order');

$result = array_combine($keys, array);

try it

Sign up to request clarification or add additional context in comments.

2 Comments

my key becomes the work order number but i want the keys to just be reset to be 0 1 ....
im marking this as good i guess i can use array_values to rebase

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.