Re: multiple random items
| From: | Zoltán Németh | Date: | Mon, 16 Jul 2007 15:15:34 +0000 |
| Subject: | Re: multiple random items | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258935@lists.php.net to get a copy of this message | ||
2007. 07. 16, hétfő keltezéssel 10.56-kor Robert Cummings ezt írta:
> On Mon, 2007-07-16 at 16:49 +0200, Zoltán Németh wrote:
> > 2007. 07. 16, hétfő keltezéssel 15.40-kor chris@aquanuke.com ezt írta:
> > > Hi I have this script which pulls 1 random item from a txt file.
> > > How would I modify it to pull 10 random items.
> > >
> > > <?php
> > > $delim = "\n";
> > > $quotefile = "names.txt";
> > > $fp = fopen($quotefile, "r");
> > > $contents = fread($fp, filesize($quotefile));
> > > $quote_arr = explode($delim,$contents);
> > > fclose($fp);
> >
> > $quotenum = 0;
> > $quotes_displayed = array();
> > while ($quotenum < 10) {
> > while (!in_array($quote_index, $quotes_displayed)) {
>
> I think you should remove the ! operator :)
oh yeah, typo
sorry
greets
Zoltán Németh
>
> Cheers,
> Rob.