Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying text from random files

Status
Not open for further replies.

kawnz

Technical User
Jan 30, 2003
67
US
I have a number of text files with comments from people, and I'd like to call them randomly to a page.

I have put all the comment files into one directory so I can call them up from that one directory. The reason I want to work with text files, is because there will be 60-odd people sending in these comment files and I don't want them to have to do anything more difficult than uploading a file.

How can I randomly display one of these files and have the font style applied to the text that is in one of these files?
 
1. Read in the directory contents. (check the PHP documentation
2. Use array_rand to pick a random file name. (see
That should solve the selection problem.

As for the text style I recommend CSS.
Load the file contents (see and enclose it into a SPAN tag.
Code:
print('<span class=&quot;commentStyle&quot;>'.$theCommentText.'</span>');
Link the created page with a <link> tag to a predefined CSS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top