Re: String parsing help
| From: | Rafael Zanetti | Date: | Wed, 20 Aug 2003 20:41:56 +0000 |
| Subject: | Re: String parsing help | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-160241@lists.php.net to get a copy of this message | ||
$vector=split( " ", $string, );
$City=$vector[0];
$State=$vector[1];
$Zip=$vector[2]:
This will not work because there cases where the city name have more than 1
word
you must get from end-to-begining
i can't think about it now, but it's a tip anyway
> $vector=split( " ", $string, );
>
>
> $City=$vector[0];
> $State=$vector[1];
> $Zip=$vector[2]:
>
> ----- Original Message -----
> From: "Matt Matijevich" <matijevich@alliancetechnologies.net>
> To: "<" <php-general@lists.php.net>
> Sent: Wednesday, August 20, 2003 5:11 PM
> Subject: [PHP] String parsing help
>
>
> > I have have a string that I need to split into 3 different variables:
> > City,State, and Zip. Here is a couple examples of the strings I need to
> > parse:
> >
> > ANCHORAGE AK 99507-6420
> > JUNEAU AK 99801
> > NORTH LITTLE ROCK AR 72118-5227
> >
> > Does anyone have an idea how I could slit this into the appropriate
> > variables, maybe some kind of regular expression? I cant use the space
> > character to split the data because some of the city names have spaces
> > in them.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>