[php_man]variables.scope[/php_man]davidjwest wrote: 2. I don't understand "static", (see I did RTFM!)
Well, i use a loop to generate the values from 1 to 100, and i store them in an array.davidjwest wrote: 3. You use a for loop in there but it only generates one random number, when I tried to change the < to a > it didn't execute at all, why use a loop? How would I get this to produce a load of random numbers?
Next i generate 1 random number, as an example how you could use it.
Offcourse you could write your own loop to generate more numbers
It executes once because, you only call getLut() once.davidjwest wrote: 5. I think I answered q3, the return function, I'm used to Basic so this is now confusing the heck out of me, for - return? I guess the whole bit of code is a subroutine so the return jumps out of it? Is that why it executes once?
Once you have the array that maps number (index of the array) to the given value you can reuse that array.
To generate 10 thingies you want:
Code: Select all
$lut = getLut();
for ($i = 0; $i < 10; ++$i)
{
echo $lut[rand(1,100)];
}