You are here: Re: Quote of the day... « PHP Programming Language « IT news, forums, messages
Re: Quote of the day...

Posted by PHPGB on 10/13/48 11:24

<comp.lang.php , , google@sigol.co.uk>
<1124402050.422587.203050@g14g2000cwa.googlegroups.com>
<18 Aug 2005 14:54:10 -0700>

> Hi I'm a newbie. I want to create a simple script that reads a text
> file (quotes.txt) and picks a quote from the file at random. There will
> be one quote per line in the file. Any help would be greatly
> appreciated.
>

I have my random quote stuff currently in the config file and i've been
meaning to convert it to a text file .

Its your lucky day as I had to write the code anyway .

phpgb_rnx_random.php can be any text file you want and the file
extension used doesnt matter .


<?php

$phpgb="phpgb_rnx_random.php";
$filename=$phpgb;
$fp=fopen($filename,"r");

$toke=0;

while (!feof($fp))
{
$jack[$toke]=fgets($fp);
$toke=$toke+1;
}

$toke=$toke-2;
fclose($fp);

$zzz=(rand()%$toke);

print "There are $toke random lines <br>";
print "Random Number = $zzz <br>";
print "$jack[$zzz] <br>";

?>


--
www.phpguestbook.co.uk

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация