September 2001
Intermediate to advanced
768 pages
32h 45m
English
array file(string filename) Reads a file into an array.
Returns:
Array containing file contents; FALSE on error
Description:
file() reads the contents of a file into an array, with each line of the file being an element of the array. Newline characters remain attached to the strings.
Warning:
Because some of the filesystem functions to read/write from files partially share the same code, one or more of the bugs reported elsewhere may also apply to this function.
3.0.8, 3.0.11: Crashes when reading from URLs on Linux 2.0.36.
3.0.8, 3.0.9: Successive calls won’t work on Solaris 2.5.1 / Apache 1.3.6.
Example:
$file_array = file("test.txt"); for($i = 0; $i < count($file_array); $i++) { echo ("\$file_array[$i] equals $file_array[$i]<br ... |
Read now
Unlock full access