Re: string concatenation with fgets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Shawn,

Your code looks cleaner then mine so i tried it and got the last entry in the txt file printed twice.


On Nov 30, 2009, at 7:07 AM, Shawn McKenzie wrote:

aurfalien@xxxxxxxxx wrote:
So here is my final test code, notice the check for ' ' in the if.

Since I'm on Linux, this has to do with whats between the last LF and
EOF which is nothing but this nothing will get printed out.

$file = fopen("somefile.txt", "r");
while (! feof($file))
   {
     $tmp = trim(fgets($file));
     if ($tmp != '')
       {
         $names = $tmp;
       }
   print $names."sometext\n";
   }
fclose($file);



--
Thanks!
-Shawn
http://www.spidean.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux