PHP pulling random line
Hi
Let's say a text document has 30 lines in it. How could PHP be used to randomly pull one of those lines, each time the web page is built? I'm looking to pull a random category or partner, or something, on my pages. PHP is not my strongest side :) Thanks anyhow J|bow|lly |
I actually know this one!!! (not that I wrote it lol)
Code:
$file = "/home/domain.com/public_html/textfile.txt"; https://www.link-o-rama.com/greenguy/mlinks.htm |
...and yes I know there's useless code in there |couch|
|
Thanks! |shake|
I will try it as soon as I can. Hopefully this week. |bow| J|banana|lly |
Quote:
(Of course you knew it worked, I mean, it works for me too :-D ) Thanks again, appreciated J|JollyHumper|lly |
|thumb
|
$f_contents = file("random_source.txt");
$line = $f_contents[rand(0, count($f_contents) - 1)]; ?> |
All times are GMT -4. The time now is 08:57 PM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc