echo Randline(); // Randline // Returns a random complete line from the file function Randline() { $infile = "idioms.txt"; $fh = fopen($infile, 'r'); // Open file $filesize = filesize($infile); // Find size of file $randnumber = rand(1, $filesize); // Pick a random integer from 1 to filesize fseek($fh, $randnumber); // Go to a random place in the file fgets($fh); // Get to end of current line $myline = fgets($fh); // Get next line fclose($fh); // Close file return strtoupper($myline); }