You are using a browser which is not compatible with CSS (for more information, see Tara's tutorial).
Because of this, it is possible that our website may not appear
correctly in your browser. We apologise for the inconvenience, and
recommend you upgrade your browser to one which is compatible with CSS.
For more information, please visit our Browser Upgrade page.
This script will output a random quote.
<?php ########################################################################### # # # Copyright © http://www.4webhelp.net/ # # Neither http://www.4webhelp.net/ nor its members accept any # # responsibility, either expressed or implied, for any damage caused by # # using this script or the misuse of this script. # # # # # # INSTRUCTIONS # # # # 1) Copy this code to an editor such as Notepad and save it with a # # .php extension. # # 2) FTP this file to a folder on your site in ASCII mode # # 3) Add your quotes - ask in our forums if you don't know how to # # 4) Call up this file in your web browser to see a quote # # # ########################################################################### $quotes[] = 'Your first quote'; $quotes[] = 'Your second quote'; $quotes[] = 'etc...'; srand ((double) microtime() * 1000000); $random_number = rand(0,count($quotes)-1); echo ($quotes[$random_number]); ?> <p>This script courtesy of <a href="http://www.4webhelp.net/">4WebHelp</a>.</p>
<? $r_array=file('quotes.txt');
shuffle($r_array);
echo $mQuotePath[0];
echo $r_array[0];
?>
had to eliminate the first echo line. After that, it worked well.
<?php
$quote=file("your-quotes.txt");
$totalnumberofquotes=count($quote);
$rdm=rand(1,$totalnumberofquotes);
echo $quote[$rdm];
?>
Just make sure that your external .txt file is in the same path as you .php file
Thanks a lot
Kind Regards,
Try using it on a page, then benchmark the page with ab (apache benchmark)....
you wont wanna use it if your site is high traffic.
The first one is to instead use double quotes when making a quote as shown by:
$quotes[] = "This is Steve's llama.";
The other way is to use single quotes and to escape the internal 's with a backslash:
$quotes[] = 'This is Steve\'s llama.';
Hope that helps.
Make a file called quotes.txt
Put each quote on it's on line.
Here's a script:
<?
$r_array=file('quotes.txt');
shuffle($r_array);
echo $mQuotePath[0];
echo $r_array[0];
?>
Also, I need a bit of help on how to incorporated it into my website since I have almost zero knowlege with html LOL
If someone could help me I'd really appreciate it!
My email is: atbdoorinc @ rogers.com ((remove spaces to reply))
My Site: http://www.picurkamonkey.com/index.html
Thank you!
$quotes[] = 'Your second quote';
$quotes[] = 'etc...';
$quotes[] = 'Your second quote';
$quotes[] = 'etc...';
?>
Add a new comment