View Single Post
Old 10-17-2020, 06:04 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Quote:
Originally Posted by Mr Pheer View Post
So I have this array like this

Code:
[location] => 2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149
What I want to do, is make it into three separate variables, like this

Code:
$city = 'Las Vegas';
$region = 'Nevada';
$zipcode = '89149';
How do I do that?

Hey, I just woke up so can't write the code but I just go through and parse it out based on the words.

something along the lines of:

$location='2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149';

$location=strtolower($location);
$city=substr($location,strpos($location,'city')+4) ;
$city=substr($city,0,strpos($city,'region');

$region=substr($location,strpos($location,'region' )+6);
$region=substr($region,0,strpos($region,'region');

$zip=substr($location,strpos($location,'zip code')+8);


There is probably a more elegant way but like I said, I just woke up ;p
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote