Generate unique random alphanumeric characters that are 7 characters long

前端 未结 15 770
予麋鹿
予麋鹿 2020-12-09 00:32

It need not be meaningful words - more like random password generation, but the catch is - they should be unique. I will be using this for some kind of package / product cod

15条回答
  •  甜味超标
    2020-12-09 01:12

    Galen's answer allows only one use of each character in the password. Not much information in that string. A simple change though:

    $chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
    $passwordlength = 7;
    for ($x = 1; $x <= $passwordlength; $x++) {
      $charlist .= $chars;
    }
    $temp_pw = substr( str_shuffle( $charlist ), 0, $passwordlength );
    

提交回复
热议问题