I have made a string generator:
<?php
function createRandomPassword() {
$chars = "abcdefghijkmnopqrstuvwxyz023456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 12) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
// Usage
$product_names = array ();
for ($i=0; $i < 100; $i++ )
$product_names[] = "code-" . createRandomPassword();
?>
My problem is that I think there is a chance this could duplicate values, and its very important that doesnt happen as I will be generating about 700,000 of them.
Is there a good way to ensure the generated strings are not duplicates?
Thanks :)