Last active
August 29, 2015 14:22
-
-
Save rlfrahm/a95616de8eb63c9761aa to your computer and use it in GitHub Desktop.
How to iterate through a CSV file using PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Open the file | |
$file = fopen($uri,'r'); | |
// If the first line is a header, uncomment the following.. | |
// $header = fgetcsv($file); | |
// Iterate through each row of the file | |
while(!feof($file)) { | |
// Read in the row | |
// $row will be an array of values that correspond to | |
// the columns in the row, example: | |
// array ( | |
// [0] => 'column_1_value', | |
// [1] => 'column_2_value', | |
// [n] => 'column_n_value', | |
// ) | |
$row = fgetcsv($file); | |
} | |
// Close the file | |
fclose($file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment