MayoorPatel
asked on
Looping through the contents of a CSV
I need to loop through the contents of a CSV and pass the values of columns 1 and 6 to a function which then does something with the values, the program should then move to the next row of the csv and grab the same column values and pass those to my function. The program should loop 10 times. Once the loop is complete the first 10 rows of the scv should be deleted.
Can someone help please?
Can someone help please?
Try this (Remeber to change 'test.csv' to your file name, change ";" to your csv delimiter and your_function to your function name):
<?
$filename = 'test.csv';
$f = file($filename);
for ($i=0; ($i<10 && $i<count($f)); $i++) {
$columns = explode(";", $f[$i]);
your_function($f[0],$f[1],$f[2],$f[3],$f[4],$f[5]);
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Flob your solution was NOT complete
ASKER
Bravo!
I don't see the difference
Open in new window