Re: Filling an array with random input doesn't quite work [message #185212 is a reply to message #185211] |
Wed, 12 March 2014 17:36 |
Tim Streater
Messages: 328 Registered: September 2010
Karma:
|
Senior Member |
|
|
In article <12lin35i3xsev(dot)abk024ld5l8l(dot)dlg(at)40tude(dot)net>, richard
<noreply(at)example(dot)com> wrote:
> $x=1;
> while ($x<40){
> $yr=range(60,69);
> shuffle($yr);
> $ayr[$x]=$yr[$x];
> echo $ayr[$x]."<br>";
> $x++;
> }
>
>
> I am attempting to load an array based upon the range of numbers 60 through
> 69.
> The array will have 40 items.
> This code produces 9 items just fine.
> The rest of the array is empty.
> What am I missing?
This:
$ayr[$x]=$yr[$x];
isn't gonna work once $x gets above 9, now is it? Your array $yr only
contains 10 items.
--
"I am enclosing two tickets to the first night of my new play; bring a
friend.... if you have one." - GB Shaw to Churchill "Cannot possibly
attend first night, will attend second... if there is one." - Winston
Churchill, in response.
|
|
|