note 28212 added to function.fgets
| From: | chip at vonburg dot com | Date: | Mon, 06 Jan 2003 12:16:18 +0000 |
| Subject: | note 28212 added to function.fgets | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41717@lists.php.net to get a copy of this message | ||
You guys are more than correct about fgets() returning the carriage return also. I ran into the same
problem and it was very frustrating to say the least. There were some great solutions here on how to
work around this, but they just seemed to be to much code for me. I was able to handle it very
easily using trim. Trim will remove all white space including carriage returns. Here is an example
of how I am doing this.
if($fp=fopen($file, "r+"))
{
while($line=trim(fgets($fp)))
{
if(!strcasecmp($line, $myline))
{
print We have a line match;
}
}
}
Hope this helps
--
http://www.php.net/manual/en/function.fgets.php
http://master.php.net/manage/user-notes.php?action=edit+28212
http://master.php.net/manage/user-notes.php?action=delete+28212
http://master.php.net/manage/user-notes.php?action=reject+28212