PHP – file() lines December 15, 2009 • 15 words • 0 min read • Updated Apr 23, 2026 #PHP $lines = file('all-words.txt'); foreach ($lines as $line_num => $line) { echo "Line number ".$line_num; } Andrew Odendaal Writing about cloud architecture, DevOps, distributed systems, and software development since 2007. About this site → Related Articles Force Download in PHP Dec 2009 shortText function toggler in php Dec 2009 Send Email PHP Function Dec 2009 PHP __autoload function Oct 2009 Sending data from javascript to php Oct 2009 Uppercase the first character of each word in a string using PHP Oct 2009 Actionscript 3 equivalent of PHP’s print_r Oct 2009 How to Remove the Last Character of a String in PHP Oct 2022