|
|
How read file content line by line in php - PHP
|
Views : 913
|
|
Tagged in : PHP
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
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 |
|
|
|