Created
July 10, 2013 20:20
-
-
Save EmeraldCoder/5969927 to your computer and use it in GitHub Desktop.
Read a csv file and return the content in an array
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
/** | |
* 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