Note Submitter: pehden at yahoo dot com
----
"heres a little script to return a random quote from a
quotes file.
<?php
$textfile = "Includes/Quotes.txt"; //quotes
file
if ($quotes = file("$textfile")) { //don't
display errors on file open
$quote = rand(0, sizeof($quotes)-1);
echo $quotes[$quote]; //echo a random
quote
}else{
echo ("default quote"); //if quotes
file wasn't found, echo out a default quote
}
?> "
I tried this code but there was on thing wrong with it
here is what i did and it works great
I removed the Includes/ thing
and now it works.
<?php
$textfile = "Quotes.txt"; //quotes file
if ($quotes = file("$textfile")) { //don't
display errors on file open
$quote = rand(0, sizeof($quotes)-1);
echo $quotes[$quote]; //echo a random
quote
}else{
echo ("default quote"); //if quotes
file wasn't found, echo out a default quote
}
?>
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|