note 54433 deleted from function.rand by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:43:37 +0000 |
| Subject: | note 54433 deleted from function.rand by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134423@lists.php.net to get a copy of this message | ||
Note Submitter: Corry Gellatly ncl.ac.uk
----
I've used this script to generate an array of random numbers with a numeric key. I got an array
of over 200,000 on this system, and got <1000 using the examples submitted previously. I
haven't managed to return the array variable outside the function, but have written it to a
database.
<?php
function rand_array($start, $end, $rangemin, $rangemax)
{
$array = array_fill($start, $end, 1);
foreach($array as $key => $value)
{
$value = rand($rangemin,$rangemax);
print "$key: $value<br>\n";
}
}
$start = 1;
$end = 1000;
$rangemin = 1;
$rangemax = 20000;
rand_array($start, $end, $rangemin, $rangemax);
?>