Created
May 15, 2024 09:37
-
-
Save catwhocode/1cb64c62446a85387c909b382104786c to your computer and use it in GitHub Desktop.
Read 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 | |
// Open the file for reading | |
if (($myfile = fopen("myfile.csv", "r")) !== FALSE) { | |
// Convert each line into the local $data variable | |
while (($data = fgetcsv($myfile, 1000, ",")) !== FALSE) { | |
// Read the data from a single line | |
$nama = $data[0]; | |
$nik = $data[1]; | |
$unit_kerja = $data[2]; | |
$email = $data[3]; | |
$is_active = 1; | |
$group_id = 6; // $data[4]; | |
$gapok = $data[5]; | |
echo $nama . ' | ' . $nik . ' | ' . $unit_kerja . "\n"; | |
} | |
// Close the file | |
fclose($myfile); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment