How can I limit the following code to generate 8 mixed characters and number in the code below.
Here is the PHP code.
md5(uniqid(rand(1,6)));
A md5 hash is always 32 characters long ; that's what an md5 is.
But you could choose to use only 8 characters from the string returned by the md5()
function, with the substr
function.
For example, to keep only the first eight characters, you could use something like this :
echo substr(md5(uniqid(rand(1,6))), 0, 8);
And it would get you something like this :
4651da2b
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