On Mon, 2007-07-16 at 16:49 +0200, Zoltán Németh wrote:
> 2007. 07. 16, hétfő keltezéssel 15.40-kor [EMAIL PROTECTED] 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)) {
Oh sure!!! Go for unique random items ;) But what happens if the file
contains less than 10 items :)
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php