Skip to content

Instantly share code, notes, and snippets.

@EmeraldCoder
Created July 10, 2013 20:20
Show Gist options
  • Save EmeraldCoder/5969927 to your computer and use it in GitHub Desktop.
Save EmeraldCoder/5969927 to your computer and use it in GitHub Desktop.
Read a csv file and return the content in an array
/**
* Read a csv file and return the content in an array
*
* @param string $filename
* @param string $delimiter
* @return array
*/
private function _convertCsvFileToArray($filename, $delimiter)
{
$result = array();
if (($handle = fopen($filename, "r")) !== false) {
while (($data = fgetcsv($handle, 0, $delimiter)) !== false) {
$result[] = $data;
}
fclose($handle);
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment