I need to generate about 100000 unique code. I have tried following code. But it is getting slower. Can anybody suggest me how can I make it faster, soon I have to generate unique code of 1M.
$uniqueArray = array();
for($i = 1; $i <= 100000; $i++) {
$pass = substr(md5(uniqid(mt_rand(), true)) , 0, 6);
if (!in_array($pass, $uniqueArray)) {
$uniqueArray[] = 'AB' . $pass;
}
}