note 54030 added to function.rand
| From: | emailfire at gmail dot com | Date: | Tue, 21 Jun 2005 14:39:13 +0000 |
| Subject: | note 54030 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90749@lists.php.net to get a copy of this message | ||
To get a random quote in a file use:
<?
$file = "quotes.txt";
$quotes = file($file);
echo $quotes[rand(0, sizeof($quotes)-1)];
?>
quotes.txt looks like:
Quote 1
Quote 2
Quote 3
Quote 4
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54030
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54030&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54030&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54030&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54030&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54030&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54030&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54030&report=yes
Search -- http://master.php.net/manage/user-notes.php