If you want to randomly read a line and print its data you could do something like this: $file = file('/link/to/text.txt'); echo $file[rand(0, count($file) - 1)]; PHP: