fileReads entire file into an arrayDescriptionarrayfilestringfilenameintuse_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.
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 second 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 a binary safe manner.
¬e.not-bin-safe;
&tip.fopen-wrapper;
See also readfile,
fopen, fsockopen, and
popen, and file_get_contents,
and include.