Today, through the experts trick tutorial website, we will understand how to generate a 32 digit number’s at random by php script code.If we talk about why a random number is used. So there is only one answer. For security purpose only we use the long generated random number. Most of all when we create a user account, random in our database Let’s use the number to save.
So let’s go.
php has only inbuilt function (mt_rand) of php to generate random number. In which you can generate any number from 0 to 9. This function supports all version of php.
For example you are given below.
mt_rand(0, 9)
How to Generate 32 Digits Random Number by PHP?
Now I will tell you how you can generate a random number of 32 digits by php using this function. Whose example is given below
generate_32_digit_random_number.php
<?php function generatenumber($limit){ $code = ''; for($i = 0; $i < $limit; $i++) { $code .= mt_rand(0, 9); } return $code; } echo generatenumber(32); ?>
You are told above by example how you can create a random number of 32 digits through php. First you have to create a file of php. You can name any file in its own way. The way is given above. Then after copying the code of php given above, you paste it in your file. And then after saving, you can try running it on your server.