note 19901 added to function.trim

From: Date: Thu, 14 Mar 2002 16:30:22 +0000
Subject: note 19901 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-27789@lists.php.net to get a copy of this message
Windows uses two characters for definining newlines, namely ASCII 13 (carriage return, "\r") and ASCII 10 (line feed, "\n") aka CRLF. So if you have a string with CRLF's, trim() won't recognize them as being one newline. To solve this you can use str_replace() to replace the CRLF's with with a space or something. <?php // string with bunch of CRLF's $my_string = "Liquid\r\nTension Experiment\r\n\r\n\r\n"; // replace CRLF's with spaces $my_wonderful_string = str_replace("\r\n", " ", $my_string); // would result in "Liquid Tension Experiment " // or just delete the CRLF's (by replacing them with nothing) $my_wonderful_string = str_replace("\r\n", "", $my_string); // would result in "LiquidTension Experiment" ?> -- http://www.php.net/manual/en/function.trim.php http://master.php.net/manage/user-notes.php?action=edit+19901 http://master.php.net/manage/user-notes.php?action=delete+19901 http://master.php.net/manage/user-notes.php?action=reject+19901

« previous php.notes (#27789) next »