Hi guys, trying to think of an elegant way of achieving the following:
- merge the "availability_" elements where the "flight_number" matches
- So that there is only one child array for each flight number (i.e. delete any further child arrays after the merge)
- Note: There won't be an occurrence where there are conflicting "availability_" values for the same flight number
FYI, if it would be easier if "availability" was a child array instead of separate elements, we can do that instead.
Thank you in advance for your help!
E.g. Turn this:
Code:
Array
(
[0] => Array
(
[flight_number] => BA0179
[availability_first] =>
[availability_business] =>
[availability_economy] => 99
)
[1] => Array
(
[flight_number] => BA0213
[availability_first] =>
[availability_business] =>
[availability_economy] => 6
)
[2] => Array
(
[flight_number] => BA0179
[availability_first] =>
[availability_business] => 1
[availability_economy] =>
)
)
Into:
Code:
Array
(
[0] => Array
(
[flight_number] => BA0179
[availability_first] =>
[availability_business] => 1
[availability_economy] => 99
)
[1] => Array
(
[flight_number] => BA0213
[availability_first] =>
[availability_business] =>
[availability_economy] => 6
)
)