Last active
February 27, 2016 01:36
-
-
Save georgestephanis/20c26b8d467aefc43aa4 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
$filename = 'csvdata.csv'; | |
header( 'Content-type: text/plain' ); | |
if ( $data = fopen( $filename, 'r' ) ) { | |
// Snag the first row as column headers | |
$cols = fgetcsv( $data ); | |
while ( ( $row = fgetcsv( $data ) ) ) { | |
// Change it to an associative array! | |
$row = array_combine( $cols, $row ); | |
// Do whatever. | |
print_r( $row ); | |
} | |
// Clean up! | |
fclose( $data ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment