• PHP Video Tutorials

PHP - Function file()



The file() function can read the entire file into an array, and each element in an array is a corresponding line in the file, including line breaks.

Syntax

array file ( string $filename [, int $flags = 0 [, resource $context ]] )

Example

<?php
   print_r(file("/PhpProject/sample.txt"));
?> 

Output

Array
(
    [0] => Tutorialspoint

    [1] => Tutorix

    [2] => TP
)
php_function_reference.htm
Advertisements