Re: Hidden new line markers?

From: Date: Mon, 24 Mar 2003 20:36:48 +0000
Subject: Re: Hidden new line markers?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-140888@lists.php.net to get a copy of this message
> The data is being entered into a textarea and is being stored as it is > entered but with an addslashes right before insertion. > > On the extract I am doing the following: > > $row[description] = stripslashes($row[description]); You don't have to use stripslashes() on data coming out of a database unless you have magic_quotes_runtime enabled. If you find that you do need to call it, then you're running addslashes() twice before the data is inserted. > $row[description] = nl2br($row[description]); > $row[description] = trim($row[description]); > > I was trying str_replace as follows but that wasn't working: > > $row[description] = str_replace("\n", "", $row[description]); This will get rid of the \n, but leave the \r there. On windows, you'll still see a newline even with just the \r remaining. If you know everything is coming from Windows, replace \r\n with an empty string. Unix uses just a plain \n and Macs use just \r, while Windows uses \r\n. Adjust your str_replace accordingly if you need to account for data from all three possible OS. ---John Holmes...

« previous php.general (#140888) next »