Skip to content

Instantly share code, notes, and snippets.

@petar-dambovaliev
Created August 25, 2016 10:17
Show Gist options
  • Save petar-dambovaliev/0ad19c50706fe252c7128fe280843f5b to your computer and use it in GitHub Desktop.
Save petar-dambovaliev/0ad19c50706fe252c7128fe280843f5b to your computer and use it in GitHub Desktop.
Creates random codes
function unique_id($l = 8) {
return substr(md5(uniqid(mt_rand(), true)), 0, $l);
}
$codes = [];
$amount = 10000;
for ($i=0; count($codes) < $amount; $i++){
$code = unique_id();
$codes[$code] = $code;
}
$file = fopen("codes.csv","w");
foreach ($codes as $code)
{
fputcsv($file,explode(',',$code));
}
fclose($file); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment