note 28248 added to function.fgets
| From: | chip at vonburg dot com | Date: | Tue, 07 Jan 2003 06:41:35 +0000 |
| Subject: | note 28248 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41777@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
--
http://www.php.net/manual/en/function.fgets.php
http://master.php.net/manage/user-notes.php?action=edit+28248
http://master.php.net/manage/user-notes.php?action=delete+28248
http://master.php.net/manage/user-notes.php?action=reject+28248