Php generate coupon or vouchers


function generate_promotion_code($no_of_codes=10, $exclude_codes_array="bb,hh", $code_length=4)
{

$characters = "0123456789 abcdefghijklmnopqrstuvwxyz";
$promotion_codes = array (); //this array is used to receive promo code generated

for ($j=0; $j <$no_of_codes; $j++)
{
$code="";
for ($i=0; $i <$code_length; $i++)
{

$code.=$characters [mt_rand (0, strlen ($characters) - 1)];

}//if the generated four random number is no longer we defined $promotion_codes function inside the

if (! In_array ($code, $promotion_codes))
{
if (is_array ($exclude_codes_array))//
{
if (! In_array ($code, $exclude_codes_array))//has ruled out using the coupon code in the
{
$promotion_codes [$j]=$code; //Will generate new promo code assigned to promotion_codes array

} else
{
$j --;

}}
 else
{
$promotion_codes [$j]=$code;//the promo code assigned to the array

}}
 else
{
$j --;

}}

return $promotion_codes;

}
echo '

Promotion/Discount Codes echo

 ';

print_r (generate_promotion_code (50, '', 4));
echo '
';


?>

Comments

Popular posts from this blog

HOW TO REGISTER FOR SAFETOKEN

Most Popular Password Cracking Tools