Last active
April 8, 2024 11:31
-
-
Save mrwadson/77a1e3d1e72fe73037d4b141fe69ee87 to your computer and use it in GitHub Desktop.
Simple read CSV files (str_getcsv)
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 | |
const CSV_FILENAME = __DIR__ . '/somefile.csv'; | |
$csvFile = file(CSV_FILENAME); | |
$data = []; | |
foreach ($csvFile as $line) { | |
$data[] = str_getcsv($line); | |
} | |
// Or | |
$csv = array_map('str_getcsv', file(CSV_FILENAME)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment