You are here: reading txt file - is empty line « All PHP « IT news, forums, messages
reading txt file - is empty line

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация