Posted By: Anonymous
I’m trying to replace multiple spaces with a single space. When I use
ereg_replace, I get an error about it being deprecated.
ereg_replace("[ tnr]+", " ", $string);
Is there an identical replacement for it. I need to replace multiple
" " white spaces and multiple
nbsp white spaces with a single white space.
preg_replace() and instead of
[ tnr] use
$output = preg_replace('!s+!', ' ', $input);
d, w and s
Shorthand character classes matching
digits, word characters (letters,
digits, and underscores), and
whitespace (spaces, tabs, and line
breaks). Can be used inside and
outside character classes.