note 8359 added to str_replace

From: Date: Thu, 07 Sep 2000 22:48:49 +0000
Subject: note 8359 added to str_replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-4464@lists.php.net to get a copy of this message
You can remove end of line characters using str_replace. $string = str_replace("\n", "", $string); However I found that sometimes there is a combination \r and \n (carriage return and line feed). You can do a one liner to remove those. $string = str_replace("\r\n", "", $string); If you are not sure what order they are in (like me), you can use a regular expression function to replace all of the possible different permutations of \r and \n. See preg_replace for more info on syntax. $string = preg_replace("/\r\n|\n\r|\n|\r/", "", $string); http://www.php.net/manual/function.str-replace.php

« previous php.notes (#4464) next »