Created
March 28, 2014 16:27
-
-
Save kostajh/9836943 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 | |
/** | |
* Read a CSV file. | |
*/ | |
public function readCSV($file) { | |
$data = array(); | |
if (file_exists($file)) { | |
$file_handle = fopen($file, 'r'); | |
while (!feof($file_handle)) { | |
$data[] = fgetcsv($file_handle); | |
} | |
fclose($file_handle); | |
// Sometimes the last row of the CSV is empty. If so, remove it. | |
if (!end($data)) { | |
array_pop($data); | |
} | |
return $data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment