LoginSignup
13
12

More than 5 years have passed since last update.

英数字のランダムパスワード作成

Last updated at Posted at 2015-07-04

パスワード自動生成の時とかに便利かと思います。


public function randString($length = 8) {
    $list = array_merge(range('0', '9'), range('a', 'z'), range('A', 'Z'));
    if ($length  < 1) {
        return false;
    }
    $str = '';
    for ($i = 1; $i <= $length; $i++) {
        $str .= $list[array_rand($list)];
    }
    return $str;
}
13
12
2

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
13
12