![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2006
Location: In front of my computer
Posts: 6
Rep Power: 0
![]() |
Random Fact Script
Hi, I am completely new to PHP so please understand if I don't understand
. I need a php scipt to put on my site that creates a random fact from a txt file. I have tried so many, but none of them seem to work. Does anyone know one or know where to good a good one? |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Nope, don't know of any, but it's reasonably easy to do. Read the file into an array, one line (fact) per element. Pick a random number in the range 0 to array length - 1 (integral). Fetch the fact from the element having that number as its index.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
King of Portal
|
Mr. John there is a previous topic in the forum regarding just what you're looking for. However it's random quotes rather than facts, but the content doesn't matter as it achieves the effect you're looking for. Here's the thread.
http://www.programmingforums.org/for...or-script.html
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jul 2006
Location: In front of my computer
Posts: 6
Rep Power: 0
![]() |
Thank you for the link. I was wondering if there was anyway I could put this code into a .tpl file. I want to add this to my phpBB board header but it doesn't seem to be working.
|
|
|
|
|
|
#5 |
|
Expert Programmer
|
You need to install the eXtreme Styles mod from phpbbstyles.com. One of its features is to allow PHP in template (.tpl) files.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Median/Mode in arrays? {Need help} | Java|Tera | Java | 27 | Nov 29th, 2005 11:50 AM |
| PHP random quote generator script | grimpirate | PHP | 10 | Sep 24th, 2005 10:22 AM |
| A simple perl script | satimis | Perl | 3 | Aug 15th, 2005 10:31 AM |
| Bash Script Help | pelon | Bash / Shell Scripting | 2 | Feb 28th, 2005 4:58 PM |