note 82548 added to function.file
| From: | jon+spamcheck at phpsitesolutions dot com | Date: | Wed, 16 Apr 2008 08:03:49 +0000 |
| Subject: | note 82548 added to function.file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138351@lists.php.net to get a copy of this message | ||
A user suggested using rtrim always, due to the line ending conflict with files that have an EOL
that differs from the server EOL.
Using rtrim with it's default character replacement is a bad solution though, as it removes all
whitespace in addition to the '\r' and '\n' characters.
A good solution using rtrim follows:
<?php
$line = rtrim($line, "\r\n") . PHP_EOL;
?>
This removes only EOL characters, and replaces with the server's EOL character, thus making
preg_* work fine when matching the EOL ($)
----
Server IP: 64.71.164.2
Probable Submitter: 24.40.216.236
----
Manual Page -- http://www.php.net/manual/en/function.file.php
Edit -- https://master.php.net/note/edit/82548
Del: integrated -- https://master.php.net/note/delete/82548/integrated
Del: useless -- https://master.php.net/note/delete/82548/useless
Del: bad code -- https://master.php.net/note/delete/82548/bad+code
Del: spam -- https://master.php.net/note/delete/82548/spam
Del: non-english -- https://master.php.net/note/delete/82548/non-english
Del: in docs -- https://master.php.net/note/delete/82548/in+docs
Del: other reasons-- https://master.php.net/note/delete/82548
Reject -- https://master.php.net/note/reject/82548
Search -- https://master.php.net/manage/user-notes.php