file Reads entire file into an array Description arrayfile stringfilename intuse_include_path Identical to readfile, except that file returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached. Upon failure, file returns &false;. Each line in the resulting array will include the line ending, so you still need to use trim if you do not want the line ending present. ¬e.line-endings; You can use the optional use_include_path parameter and set it to "1", if you want to search for the file in the include_path, too. $line) { echo "Line #{$line_num} : " . htmlspecialchars($line) . "
\n"; } // Another example, let's get a web page into a string. See also file_get_contents(). $html = implode ('', file ('http://www.example.com/')); ?> ]]>
As of PHP 4.3.0 you can use file_get_contents to return the contents of a file as a string. In PHP 4.3.0 file became binary safe. &tip.fopen-wrapper; See also readfile, fopen, fsockopen, and popen, and file_get_contents, and include.