Re: Removing Spaces From A string

From: Date: Mon, 05 May 2003 02:03:34 +0000
Subject: Re: Removing Spaces From A string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146396@lists.php.net to get a copy of this message
Richard, $str = "101 CONVENTION CENTER DR #700 Your City NV89999"; $str = preg_replace("/(\s){3,}/",",",$str); echo $str; Output: 101 CONVENTION CENTER DR #700,Your City,NV89999 This replaces a group of 3 or more spaces with a comma. Joseph "Richard Kurth" <rdkurth@starband.net> wrote in message news:160100357566.20030504184705@starband.net... > I have a text string that has multiple spaces in between address and > City and between City and State. I need away to remove all the spaces > to something like a , but I do not what to remove the spaces between > the words in the address or City. The multiple spaces are not always > the same amount of spaces. Below is an example of what the text string > looks like. > > > 101 CONVENTION CENTER DR #700 Your City > NV89999- >

« previous php.general (#146396) next »