I have a php string that outputs like this:
San Jose, California
I need the php string to output like this:
SanJose, Caliornia
I've been playing around with str_replace but not having much luck.
Any help would be appreciated!
I have a php string that outputs like this:
San Jose, California
I need the php string to output like this:
SanJose, Caliornia
I've been playing around with str_replace but not having much luck.
Any help would be appreciated!
Update: first explode with
$string = explode(",",$string);
then do for all value of $string ( in foreach for example )
For just spaces, use str_replace:
$string = str_replace(' ', '', $string);
For all whitespace, use preg_replace:
$string = preg_replace('/\s+/', '', $string);
look at here How to strip all spaces out of a string in php?