$file = "lul.txt"; // File $fileo = fopen($file , 'r'); // Open $file for reading /* Will select a random number between the minimal and maximal integer and pass to fgets */ $random = rand(1, 20); // see above. $randomproxy = fgets($fileo, $random); // Defines $randomproxy as a random line from $file echo $randomproxy; // Echos it.