RoCk RoCk - 11 months ago 34
PHP Question

How Can I Produced Alpha Numeric In Php/SQL And Which Is A Better Approach?

Good day, I just would like to ask if how can I generate random Alpha Numeric characters using PHP code / MySQL Code. I want to insert these values as unique Id for the user. Instead of using the AI in MySQL.
It may sound stupid, but Which is better (Approach)?
Generating Unique Id, using Php/Sql programmatically?.
Range could be minimum of 20+ characters. E.g gHs51hJkw9106bwkdHwPV752


You can use this code below . Its associated with the current timestamp so that its unique as you are planning to use it for AI .

$len =22;

$rand = substr(str_shuffle(md5(time())),0,$len);

echo $rand;