Thread: PHP Question
View Single Post
Old 09-27-2003, 10:51 PM  
version4
Registered User
 
Join Date: Mar 2003
Posts: 13
PHP Question

I've been using the below php script to randomly take a single line from the file test.txt and insert it into a webpage.

Could someone tell me how I could add a variable X to this script so that I can set it to whatever I want, eg x=5. In this case, the script would take 5 lines from test.txt and insert it into a webpage.

Thanks


<?php
$file = "test.txt";
$file_Content = file($file);

if (count($file_Content) > 0) {
$line = $file_Content[rand(0,count($file_Content)-1)];

echo $line;
}
?>
version4 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote