For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > November 2005 > Why is this not stripping the newlines/returns from my HTML text area?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Why is this not stripping the newlines/returns from my HTML text area?
worzel

2005-11-18, 7:55 am

$string=eregi_replace("\n\r","",$_POST['address']);

Why is this not stripping the newlines/returns from my HTML text area? How
do i do this - do in jsp easy, asp very easy, but in php it gives me
headache!

my text are is wrap="soft" (and testing with ie in which this default
anyway) i cannot see nothing wrong -even when i try str_replace() and other
methods.


Michael Meckelein

2005-11-18, 7:55 am

"worzel" wrote
> $string=eregi_replace("\n\r","",$_POST['address']);
>
> Why is this not stripping the newlines/returns from my HTML text area? How
> do i do this - do in jsp easy, asp very easy, but in php it gives me
> headache!


Are you looking for?



$string=eregi_replace("[\n\r]","",$_POST['address']);



Or do you want remove carriage returns / line feeds



$string=eregi_replace("\r\n","",$_POST['address']);



Michael




worzel

2005-11-18, 7:55 am

>>Or do you want remove carriage returns / line feeds

yes, remove 'em. $string=eregi_replace("\r\n","",$_POST['address']); aint
working.

>("[\n\r] - whats with the "[" bits here? either of them instead of the
>sequence??



"Michael Meckelein" <michael@go-on-line.de> wrote in message
news:437dc5a1$0$7438$9b4e6d93@newsread4.arcor-online.net...
> "worzel" wrote
>
> Are you looking for?
>
>
>
> $string=eregi_replace("[\n\r]","",$_POST['address']);
>
>
>
> Or do you want remove carriage returns / line feeds
>
>
>
> $string=eregi_replace("\r\n","",$_POST['address']);
>
>
>
> Michael
>
>
>
>



Michael Meckelein

2005-11-18, 7:55 am

"worzel" wrote
>
> yes, remove 'em. $string=eregi_replace("\r\n","",$_POST['address']); aint
> working.


Hmm, it is working in my environment.
[color=darkred]
>

Right. If I remember correctly I saw labs where only \n was used.

Please perfrom a simple check. Use GET instead of POST, and take a look at
the query string if there are really carriage returns / line feeds.

Michael


Connector5

2005-11-18, 7:55 am


/* Note that the default replacement is a single space */
function strip_eol($input_string = "", $replacement = " ")
{
if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))
{
return str_replace("\r\n", $replacement, $input_string);
}
else
{
return str_replace("\n", $replacement, $input_string);
}
}




"worzel" <asda@sdarta.com> wrote in message
news:437dbeb8$0$22512$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> $string=eregi_replace("\n\r","",$_POST['address']);
>
> Why is this not stripping the newlines/returns from my HTML text area? How
> do i do this - do in jsp easy, asp very easy, but in php it gives me
> headache!
>
> my text are is wrap="soft" (and testing with ie in which this default
> anyway) i cannot see nothing wrong -even when i try str_replace() and

other
> methods.
>
>



worzel

2005-11-18, 7:55 am

yes, sorry, i did change to see the query string earlier - the text area
encodes as:

lineOne%0D%0AlineTwo%0D%0AlineThree%0D%0
AlineFour

%0D%0A are line breaks right? I have tried a variety of ways to do this with
this assumption too.

Cheers, appreciate your assistance here.


"Michael Meckelein" <michael@go-on-line.de> wrote in message
news:437dd170$0$7426$9b4e6d93@newsread4.arcor-online.net...
> "worzel" wrote
>
> Hmm, it is working in my environment.
>
>
> Right. If I remember correctly I saw labs where only \n was used.
>
> Please perfrom a simple check. Use GET instead of POST, and take a look at
> the query string if there are really carriage returns / line feeds.
>
> Michael
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com