Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* 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);
// Sometimes the last row of the CSV is empty. If so, remove it.
if (!end($data)) {
return $data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment