I want to generate 20 characters of hash code in php and insert in to table and the hash code should be unique.
And later the hash code can be used to access records in table.
<?php
echo uniqid();
//generate 20 charcter alphanumeric id here
?>
How can i do this?
Try this, it will always generate a different, unique string dependent on microtime and random number.
<?php
// Here microtime will be unique everytime
echo substr(md5(microtime()*rand(0,9999)),0,20);
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With