Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Have a CSV file like this:
First|Last|Email|EmpID|SupervisorID|City|
Frank|Rizzo|frank.rizzo@gmail.com|99999|88888|Yonkers|
Sol|Rosenberg|sol.rosenberg@msn.com|88888|56565|Queens|

Ideally want to compare the second numeric column to the first numeric column and if it finds a match, grab the email of the match and append that column. Since the above has a match, it would generate:

Frank|Rizzo|frank.rizzo@gmail.com|99999|88888|Yonkers|sol.rosenberg@msn.com|

What I have tried:

Tried duplicating source file and doing a match of two arrays, but that's silly, got to be a way with one array. Use two different indexes and loop through same single array generated from CSV file?
Posted
Updated 22-May-18 21:57pm

1 solution

Quote:
Use two different indexes and loop through same single array generated from CSV file?
Exactly.


Thats' tipically done with two nested loop like:
PHP
for ($i = 0; $i < ($N-1); $i++) 
  for ($k = ($i+1); $k < $N; $k++)
  {
    //...
  }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900