RE: [PHP] fgets question

From: Date: Wed, 14 Aug 2002 18:12:05 +0000
Subject: RE: [PHP] fgets question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112568@lists.php.net to get a copy of this message
[snip] 1%0A2%0A3%0A4%0A5%0A6%0A7%0A8%0A No extra newlines that I could see. >> >>1\n >>2\n >>3\n >>4\n >>5\n >>6\n >>7\n >>8\n >> >>I create this PHP program and run it: >> >><?php >>$fd = fopen ("test","r"); >>while (!feof ($fd)) { >> $buffer = fgets($fd, 4096); >> echo "buffer is $buffer"; >>} >>fclose ($fd); >>?> The only way that I can see to do this is to test the output before printing while (!feof ($fd)) { $buffer = fgets($fd, 4096); if($buffer > 0){ echo "buffer is $buffer"; } } Or I suppose you could say if(!$buffer), will make for less code HTH! Jay *********************************************************** * Texas PHP Developers Conf Spring 2003 * * T Bar M Resort & Conference Center * * New Braunfels, Texas * * San Antonio Area PHP Developers Group * * Interested? Contact jay.blanchard@niicommunications.com * ***********************************************************

« previous php.general (#112568) next »