note 28248 deleted from function.fgets by sniper
| From: | sniper@php.net | Date: | Sat, 08 Feb 2003 20:12:20 +0000 |
| Subject: | note 28248 deleted from function.fgets by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43663@lists.php.net to get a copy of this message | ||
It is absolutely correct that fgets does return the carriage return at the end of a line which can
be very frustrating. Although there were some good solutions above, I was able to solve this problem
by simply using trim. Here is an example:
if($fp=fopen($file, "r+"))
{
while($line=trim(fgets($fp)))
{
if(!strcasecmp($line, $myline))
{
print We have a match;
}
}
}
Hope this helps