In this article, we will know you how to generate random alphanumeric string in PHP. we will see a simple example of generate random string in PHP.
Sometimes we have to random alphanumeric string. such as generate a token. so we are using the md5() function in this example. so you can see the below example.
<?php function random_strings($length_of_string) { return substr(md5(time()), 0, $length_of_string); } // Random string of length 8 echo random_strings(8); echo "<br/>"; // Random string of length 6 echo random_strings(6); ?>
Please follow and like us: