Assuming your txt file is comma-separated text like this:
"joe", "blow"
"john", "doe"
"first name", "last name"
<?php
$maxLineLength = 1000; // set this large enough to be longer than any given line
$filename = 'textFile.txt'; // change this to point to your text file
$handle = fopen($filename, "r")
or die('could not open file ' . $filename);
$lineCount = 0;
$allLines = array();
while (($line = fgetcsv($handle, 1000, ",")) !== FALSE) {
$allLines[$lineCount] = $line;
$lineCount++;
}
fclose($handle);
$min = 0;
$max = $lineCount-1;
$n = rand($min, $max);
$lineChosen = $allLines($n);
echo 'the result is ' . $lineChosen[0] . ' ' . $lineChosen[1];
?>