1// Read the whole file into a array.
2$file = file('File Location');
3
4// Getting the Words Count in the file.
5$wCount = count($file);
6
7// Printing out the random word.
8echo $file[rand(0, $wCount - 1)];
9
10// This is a one liner.
11echo file('File Location')[rand(0, count(file('File Location')) - 1)];