Skip to content Skip to sidebar Skip to footer

How to read file using PHP

Reading Time: < 1 minute

How to read file using php.Following example is describes how to read and display file content using php.php fopen() and fread() functions will help to do this.

1-Read Text File

Download PHP Read Text File Example(2 KB)
2-Read CSV File

while($csv_line = fgetcsv($fp,1024)) {
    print '';
    for ($i = 0, $j = count($csv_line); $i < $j; $i++) {
        print ''.$csv_line[$i].'';
    print "\n";
print '';
fclose($fp) or die("can't close file");

Download PHP Read CSV File Example(2 KB)