1

I have 2 arrays converted from csv files using php-csv-parser. This is the oldest file:

Array
(
[0] => Array
    (
        [0] => A Single Man
        [1] => Tom Ford
        [2] => 2009
        [3] => Somestring
    )

[1] => Array
    (
        [0] => Bram Stoker Dracula
        [1] => Francis F. Coppola
        [2] => 1992
        [3] => Somestring
    )
)

This is the newest:

Array
(
[0] => Array //this is a new record
    (
        [0] => A Single Man
        [1] => Tom Ford
        [2] => 1988
    )

[1] => Array //this record already exists in oldest array
    (
        [0] => A Single Man
        [1] => Tom Ford
        [2] => 2009
    )

[2] => Array //this record already exists but has a modify
    (
        [0] => Bram Stoker Dracula
        [1] => Francis Ford Coppola //modified string
        [2] => 1992
    )
)

I want to create third "merged" array, that contains new records and modified strings taken from newer. Please note that i have to create a new record if Array[i][2] are different strings, but simply modify the record if any other parameter changes. Afterwards for each new record i have to fill all other empty parameters.

That's the expected output

Array
(
[0] => Array
    (
        [0] => A Single Man
        [1] => Tom Ford
        [2] => 1988
        [3] => //empty for now, to fill
    )

[1] => Array
    (
        [0] => A Single Man
        [1] => Tom Ford
        [2] => 2009
        [3] => Somestring
    )

[2] => Array
    (
        [0] => Bram Stoker Dracula
        [1] => Francis Ford Coppola
        [2] => 1992
        [3] => Somestring
    )
)

0 Answers0