get keyfield from one csv file and search for it in another csv file and output

file1.csv:

0|john smith|london|23
1|david adams|bath|35
2|sean white|liverpool|61

file2.csv:

1|boat|car|train
0|scooter|moped|aircraft|
2|walk|cycle|run

I want to use php. The first number in both files is the key field. I want to open the first file, and go through all the keyfields one by one. If the keyfield in the first file matches the keyfield in the second file, then output the data from the same row in the second file.

output will be :

john uses a scooter, moped and aircraft sean walks, cycles and runs and david uses boat, car and train

Thanks for your help on this, I’m losing sleep…!

What do you have so far?

Sponsor our Newsletter | Privacy Policy | Terms of Service