LoginSignup
1
0

More than 1 year has passed since last update.

PHP ランダム文字列生成

Last updated at Posted at 2022-03-14

ランダム文字列生成 (a~zの中で生成) 32桁 for文の数値変更すれば桁数変更できる

$str = chr(mt_rand(97, 122));
        for($i = 1; $i < 32; $i++){
            $str .= chr(mt_rand(97, 122));
        }

ランダム文字列生成 (A~Zの中で生成)

$str = chr(mt_rand(65, 90));
        for($i = 1; $i < 32; $i++){
            $str .= chr(mt_rand(65, 90));
        }

乱数生成

rand()
rand(5,8) //5~8の間で生成
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0