Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Merge child array values (tricky q)

    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
            )
    )
    Last edited by benwiggy; 12-28-2012 at 07:57 PM. Reason: extra information


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •