How read file content line by line in php
by kalai[ Edit ] 2009-04-22 19:25:03
Inorder to read file content line by line, first read file content and store it in a variable.
Convert new line to break line ie,
to
using nl2br() function.
Explode using delimiter
and store it in an array.
When you print the array, you will get each line of file content.
<?php
$file = "fiel1.txt";
$open = fopen($file, "r");
$size = filesize($file);
$count = fread($open, $size);
$cnt=nl2br($count);
$line = explode('<br />',$cnt);
for($k=0;$k<count($line);$k++)
{
echo"$line[$k]";
}
?>