View Single Post
Old 10-17-2020, 06:20 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
Quote:
Originally Posted by k0nr4d View Post
It's to offset the number of characters but it's wrong, because he didn't factor in the : and the space after it. He also left out two )'s
You do it before coffee damnit.

However if you are doing an array it is probably more like this:

$location=array('2020-10-16 04:08PM -0700
City: Las Vegas
Region: Nevada
Zip Code: 89149',
'2020-10-16 04:08PM -0700
City: Las Vegas2
Region: Nevada2
Zip Code: 89150',
'2020-10-16 04:08PM -0700
City: Las Vegas3
Region: Nevada3
Zip Code: 89151',
'2020-10-16 04:08PM -0700
City: Las Vegas4
Region: Nevada4
Zip Code: 89152');

$newlocation=array();
foreach($location as $loc)
{
$city=substr($loc,strpos($loc,'city')+5);
$newlocation[]['city']=substr($city,0,strpos($city,'region'));

$region=substr($loc,strpos($loc,'region')+7);
$newlocation[]['region']=substr($region,0,strpos($region,'region'));

$newlocation[]['zip code']=substr($loc,strpos($loc,'zip code')+9);
}

var_dump($newlocation);


-------------------------

And that one doesn't leave off the )'s and it assumes that the order of the vars is the same.

.
__________________
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