I am trying to create promo codes in large batches (with php / mysql).
My code currently looks something like this:
$CurrentCodesInMyDB = "asdfasdf,asdfsdfx";
$PromoCodes = "";
for($i=0;$i<=30000;$i++)
{
$NewCode = GetNewCode($PromoCodes, $CurrentCodesInMyDB );
$PromoCodes .= $NewCode . ",";
}
function GetNewCode($CurrentList, $ExistingList)
{
$NewPromo = GetRandomString();
if(strpos($CurrentList, $NewPromo) === false && strpos($ExistingList, $NewPromo) === false)
{
return $NewPromo;
}
else
{
return GetNewCode($CurrentList, $ExistingList);
}
}
function GetRandomString()
{
return "xc34cv87";
}
When I make parties in 10k, everything seems to be in order. But the client would like to be able to generate 30 thousand at a time. When I hit the loop up to 30k, I have problems. Are there any obvious performance improvements that I could make, or maybe in another way I could do this?
Jason source
share