] String parsing help
From: Jonatan Pugliese. [EMAIL PROTECTED]
From: Matt Matijevich [EMAIL PROTECTED]
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
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
$vector=split( , $string, );
$City=$vector[0];
$State=$vector[1];
$Zip=$vector[2]:
- Original Message -
From: Matt Matijevich [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, August 20, 2003 5:11 PM
Subject: [PHP] String parsing help
I have have a string that I need
* Thus wrote Matt Matijevich ([EMAIL PROTECTED]):
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
=$vector[0];
$State=$vector[1];
$Zip=$vector[2]:
- Original Message -
From: Matt Matijevich [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
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
From: Jonatan Pugliese. [EMAIL PROTECTED]
From: Matt Matijevich [EMAIL PROTECTED]
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
Or (untested):
$String = 'NORTH LITTLE ROCK AR 72118-5227';
$Bits = split(strrev($String), '[[:space:]]+', 3);
$Zip = strrev($Bits[0]);
$State = strrev($Bits[1]);
$City = strrev($Bits[2]);
...could also use preg_split()
- steve
At 4:44 PM -0400 8/20/03, CPT John W. Holmes
[EMAIL PROTECTED]
7 matches
Mail list logo