Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-28-2012, 01:22 AM   PM User | #1
benwiggy
New to the CF scene

 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
benwiggy is an unknown quantity at this point
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 06:57 PM.. Reason: extra information
benwiggy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:39 PM.


Advertisement
Log in to turn off these ads.