Generate 10 (Ten) Digit Unique Random Number With PHP?

Friends random number more when we post a blog or article. So a random number is generated to create the unique id of all the posts. So today we will tell you how you can generate a random number of 10 digits by php.You are given the code as an example below.

<?php 
function generateCode($limit){
$code = '';
for($i = 0; $i < $limit; $i++) { $code .= mt_rand(0, 9); }
return $code;
}
echo generateCode(10);
?>

How to use this Code?

Now you will be told how you can use this code. First of all you create a file named tendigit.php. Then copy the above code and paste it into the file you created. Run this code on your server and you will get the output.

If you find this post help ful, please do not forget to share this post.