PHP - Generate an 8 character hash from an integer

前端 未结 6 1157
青春惊慌失措
青春惊慌失措 2020-12-17 00:05

Is there a way to take any number, from say, 1 to 40000 and generate an 8 character hash?

I was thinking of using base_convert but couldn\'t figure out

6条回答
  •  情话喂你
    2020-12-17 00:37

    there are many ways ...

    one example

    $x = ?
    $s = '';
    for ($i=0;$i<8;++$i)
    {
        $s .= chr( $x%26 + ord('a') );
        $x /= 26;
    }
    

提交回复
热议问题