For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > November 2005 > Re: Why is this not stripping the newlines/returns from my HTMLtext 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 Re: Why is this not stripping the newlines/returns from my HTMLtext area?
puneet.kandhari@gmail.com

2005-11-22, 6:56 pm

function clearSpaces($str){
$keywordDisallow = array(
"\n" => "",
"\t" => "",
"\r" => ""
);
foreach ($keywordDisallow as $key => $val){
$str =& str_replace($key, $val, $str);
}
$str =& preg_replace("(\s+)", " ", $str);
return trim($str);
}

That should be a useful way to do it.

worzel wrote:[color=darkred]
> $string=eregi_replace("[\n\r]+","",$_POST['address']); This did the trick!
>
> Seems to be this is a very basic thing yet it seems no definitive function
> to do it? I ws barking up the right tree, knoew what the issues were, yet
> still found it a tricky thing to pin down? Is there no dedicated function fo
> rthis, must catch a few folk off guard??
>
> Anyway, thanks man, very much appreciated.
>
> "Philip Ronan" <invalid@invalid.invalid> wrote in message
> news:BFA3869E.3B142%invalid@invalid.invalid...

Sponsored Links







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

Copyright 2008 codecomments.com