Generate alphanumeric random number in php

Today, We want to share with you generate alphanumeric random number in php.In this post we will show you random alphanumeric generator php, hear for php generate random number we will give you demo and example for implement.In this post, we will learn about generate a random, unique, alphanumeric string in PHP with an example.

PHP generate random alphanumeric string

Using str_shuffle() Function:

Example 1:

$length = 10;
$data = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcefghijklmnopqrstuvwxyz';
 
echo substr(str_shuffle($data), 0, $length);
echo "
"; echo substr(str_shuffle($data), 0, 8);

Output

0ImfBgRN5D
N8XYK13e

Using md5() Function:

Example 2:

echo substr(md5(microtime()), 0, 10); 
echo substr(md5(microtime()), 0, 8); 
 
// output
1938cf9403
550e4d5a

I hope you get an idea about php generate random alphanumeric string .
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment