How read file content line by line in php - PHP Views : 913
Tagged in : PHP
0 0
Send mail
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]";
}
?>
By kalai, On - 2009-04-22



    Login to add Comments .