Random ID/Number Generator in PHP

前端 未结 4 1412
伪装坚强ぢ
伪装坚强ぢ 2021-01-17 05:29

I am building a list of \"agent id\'s\" in my database with the following requirements:

  1. The ID must be 9 digits long (numeric only)
  2. The ID may not con
4条回答
  •  一生所求
    2021-01-17 06:12

    Try this code:

    = 2)
            {
                while(($random_agtno % 100) == $digits[0])
                    shuffle($digits);
            }*/
            $random_agtno *= 10;
            $random_agtno += $digits[0];
            array_splice($digits, 0, 1);
        }
        return $random_agtno;
    }
    
    for($i = 0; $i < 1000; $i++)
    {
        $NEWAGTNO = createRandomAGTNO();
        echo "

    "; echo $NEWAGTNO; echo "

    "; } ?>

    Good luck!

    Edit: Removed the call to srand() and commented-out the "if($i >= 2)" code, which is impossible anyway, here.

提交回复
热议问题