Generate unique random alphanumeric characters that are 7 characters long

前端 未结 15 736
予麋鹿
予麋鹿 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:04

    Heres a very simple way

    $chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
    $temp_pw = substr( str_shuffle( $chars ), 0, 7 );
    if ( check_unique( $temp_pw ) ) {
        $pw = $temp_pw;
    }
    

    You'll have to implement your own check_unique function. That part should be easy.

提交回复
热议问题