php - replace array elements with another array's elements?

Posted by Simpson88Keys on Stack Overflow See other posts from Stack Overflow or by Simpson88Keys
Published on 2010-05-26T01:14:49Z Indexed on 2010/05/26 1:21 UTC
Read the original article Hit count: 331

Filed under:
|
|

Not sure how to go about this...

But, I have two arrays, one with updated information, another with outdated information... There are a lot more elements in the second array, but I'm looking to "update" the outdated one with the updated information.

Here's what the arrays look like:

//Outdated
Array (
    [0] => Array
        (
            [anum] => 3236468462
            [cid] => 4899097762
            [mid] => 1104881401  
            [na_title] =>         
            [na_fname] => JOHN                   
            [m_initial] =>  
            [na_lname] => DOE           
            [na_suffix] =>     
            [na_addr1] => 1234 SAMPLE AVENUE           
            [na_addr2] =>                             
            [na_city] => NORWALK           
            [state] => OH
            [zip] => 
            [zip_plus_4] => 
            [route] => R002
            [dma_code] => 510334
        )
)


//Updated
Array (
    [1] => Array
        (
            [0] => YUD990
            [1] => 98
            [2] => 1234 Sample Avenue
            [3] => 
            [4] => Norwalk
            [5] => OH
            [6] => 44857-9215
            [7] => 3236468462
        )
)

To clarify, I want to:

(1) Match up the value for [7] from the updated array with the value for [anum] in the outdated array, and then update [na_addr1], [na_addr2], [na_city], [state], [zip], [zip_plus_4] in the outdated array with the values for [2],[3],[4],[5],[6] (I know I'll need to split the updated [6] in order to get it to map corrected to the outdated)

Feel like I'm making this very confusing... sorry about that...

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays