I have a multidimensional array and then another array where the structure is similar but not identical (it shares common keys).
It looks something like this:
[my_Array] => Array
(
[0] => Array
(
[title] => o1
[item_details] => original item 1
[booking_date] => 2015-02-14
[booking_start] => 18:30:00
[booking_end] => 18:35:00
)
[1] => Array
(
[title] => o2
[item_details] => original item 2
[booking_date] => 2015-02-14
[booking_start] => 19:30:00
[booking_end] => 19:35:00
)
)
[new_array] => Array
(
[item_details] => new item
[booking_date] => 2015-02-14
[booking_start] => 18:55:00
)
The first array is already ordered on the booking_start key, but I want to push the new array item to the first array in order of booking_start.
I'm guessing that array splice is my friend here but how work out what position I need to push to?
So my result would look like this:
[my_Array] => Array
(
[0] => Array
(
[title] => o1
[item_details] => original item 1
[booking_date] => 2015-02-14
[booking_start] => 18:30:00
[booking_end] => 18:35:00
)
[1] => Array
(
[item_details] => new item
[booking_date] => 2015-02-14
[booking_start] => 18:55:00
)
[2] => Array
(
[title] => o2
[item_details] => original item 2
[booking_date] => 2015-02-14
[booking_start] => 19:30:00
[booking_end] => 19:35:00
)
)
array_splice? Why not just push and reorder withusort?