$data = file("words.txt"); sort($data); for ($i = 0; $i < count($data); $i++) { echo $data[$i] . "\n"; }