Link to home
Start Free TrialLog in
Avatar of server_room
server_roomFlag for United States of America

asked on

Removing white spaces in a string

I have hundreds of strings in an array that need to be seperated as in city and state

example:

*************************

Eatontown   NJ

Hazlet      NJ

Highland Park       NJ

etc...


btw, all these strings have a variant amount of spaces :(
So I can't just do explode()
*************************

Is there a way to get these seperated?
ASKER CERTIFIED SOLUTION
Avatar of wide_awake
wide_awake

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of server_room

ASKER

You almost had it but I modified it to this and it worked!

list($city, $state) = split(' + +', $stringToSplit);

Thanks!
Your solution worked! Thanks again!
Avatar of wide_awake
wide_awake

Glad it helped.