Posted by Jerry on 07/09/05 06:36
How can you read a .txt file and only show the lines that are NOT empty.
I have a .txt file that has the following and want only to echo the lines
that have values in them...
sample txt file content
"
Joe West
Friend & Neighbor
(604) 123-1234
--------------------------------------------------------------------------------
Joe Five
Friend
(604) 123123123
"
Output should be something like this
"
Joe West
Friend & Neighbor
(604) 123-1234
Joe Five
Friend
(604) 123123123
"
I have tried this, but not having any luck ...
<?php
$handle = fopen("sp.txt", "r");
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
if (!empty($buffer))
{
echo $buffer;
echo "<BR>";
}
$buffer = "";
}
fclose($handle);
?>
thanks!
Navigation:
[Reply to this message]
|