Page 1 of 1

[solved] removing spaces

Posted: Tue Jan 18, 2005 6:20 am
by irealms
Is str_replace the best way of removing a space from a number or text?

Posted: Tue Jan 18, 2005 6:25 am
by neophyte
It's one way. You could also use trim() if you know the whitespace is at the beginning or end. Regular expressions might be a second option. preg_replace(). I'd use str_replace() before preg_replace().

Posted: Tue Jan 18, 2005 6:26 am
by irealms
Yeah the space is in the middle, i'll stick to str_replace, thanks. :)

Posted: Tue Jan 18, 2005 8:13 am
by feyd
a preg_replace example of removing spaces can be found here:

viewtopic.php?t=29465