Created
October 5, 2019 05:52
-
-
Save caironm/3c4061332cdc9bf183991c6efa959d7b to your computer and use it in GitHub Desktop.
Abrindo CSV
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 | |
function getRows($file) { | |
$handle = fopen($file, 'rb'); | |
if (!$handle) { | |
throw new Exception(); | |
} | |
while (!feof($handle)) { | |
yield fgetcsv($handle); | |
} | |
fclose($handle); | |
} | |
foreach (getRows('data.csv') as $row) { | |
print_r($row); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment