Created
August 2, 2022 04:05
-
-
Save omar-faruk-sust/98fc3646ee567af58f8a8d19b190e2a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$list[] = array ("name","gender","age"); | |
$values = [ | |
array("Hello","M","21"), | |
array("Syed","M","30"), | |
array("Rishat","F","25") | |
]; | |
for($i = 0; $i < 20000; $i++) { | |
$list[] = $values[rand(0,2)]; | |
} | |
$filename = __DIR__ . "/files/" . "myCSV.csv"; | |
if(file_exists($filename)) { | |
unset($list[0]); | |
$handle = fopen($filename, "a"); | |
foreach ($list as $fields) { | |
fputcsv($handle, $fields); | |
} | |
fclose($handle); | |
} else { | |
$fp = fopen($filename, 'w'); | |
foreach ($list as $fields) { | |
fputcsv($fp, $fields); | |
} | |
fclose($fp); | |
} | |
echo "done"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment