Page 1 of 1

remove spaces - no line brakes

Posted: Sat Mar 04, 2006 5:21 am
by pedroz
I have this funtion below to:
1. remove multiple spaces from textarea
2. space at the end of the string...

Code: Select all

function space($string) {	
$string = eregi_replace('^[[]]+', '',preg_replace('/\s+/', ' ', $string));	
return $string; 
}
How can avoid removing the line breaks?

example:
Hi...
How are you?

with the function above it will result
Hi... How are you?

... removing me the line break and I only want to remove extra spaces

Posted: Sat Mar 04, 2006 6:03 am
by kreoton
i think function nl2br()may help you ;)

Posted: Sat Mar 04, 2006 5:43 pm
by pedroz
I found it... Thanks!

Code: Select all

$string = eregi_replace('^[[]]+', '', ereg_replace (' +', ' ', $string));