PHP 生成N随机数

2018-04-17  本文已影响0人  NemoWei

例:生成4位随机数

$code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);

str_pad 使用另一个字符串填充字符串为指定长度
string str_pad ( string $input , int $pad_length [, string $pad_string = " " [, int $pad_type = STR_PAD_RIGHT ]] )

上一篇 下一篇

猜你喜欢

热点阅读