note 31579 deleted from function.rand by aidan
| From: | aidan@php.net | Date: | Sat, 11 Sep 2004 07:43:25 +0000 |
| Subject: | note 31579 deleted from function.rand by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76455@lists.php.net to get a copy of this message | ||
Note Submitter: wicked_wesley at atari dot nl
----
You can easy make a large random number, with a small function. Here it goes:
<?php
function randomNr($number)
{
if($number)
{
for($i=1;$i<=$number;$i++)
{
$nr=rand(0,9);
$total=$total.$nr;
}
return $total;
}
}
?>
Just call this function like this:
randomNr(some_number);
Example:
$random=randomNr(4);
returns a number between 0 and 9999
$random=randomNr(6);
returns a number between 0 and 999999
$random=randomNr(9999);
This does work and pretty fast too, too long to post :)
Hope it helps,
Wesley