Syntax
array file ( string $filename [, int $flags [, resource $context]] ); |
Definition and Usage
Reads an entire file into an array.
Paramters
Parameter | Description |
---|---|
filename | Path to the file. |
flags | The optional parameter flags can be one, or more, of the following constants:
|
context | A context resource created with the stream_context_create() function. |
Return Value
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.
Example
Following is the usage of this function:
<?php // Get a file into an array. $lines = file('http://www.tutorialspoint.com/'); // Loop through our array, foreach ($lines as $line_num => $line) { echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) echo "<br />\n"; } ?> |
No comments:
Post a Comment