fileReads entire file into an arrayDescriptionarrayfilestringfilenameintuse_include_pathresourcecontext
Identical to file_get_contents, 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;.
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/'));
?>
]]>
&tip.fopen-wrapper;
Each line in the resulting array will include the line ending, so you
still need to use rtrim if you do not want the line
ending present.
¬e.line-endings;
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.
¬e.context-support;
&warn.ssl-non-standard;
See also readfile,
fopen, fsockopen,
popen, file_get_contents,
and include.