BCoral BCoral - 5 months ago 8
PHP Question

Get numbers from array(Lat Long ) in PHP

I am receiving an array with strings of Lat/Long in PHP from android like this:

$array = array(
"parametros1" =>"lat/lng: (-33.36808,-70.74779)",
"parametros2" =>"lat/lng: (-33.36826,-70.74685)",
"parametros3" =>"lat/lng: (-33.36867,-70.745)",
"parametros4" =>"lat/lng: (-33.36875,-70.74462)",
"parametros5" =>"lat/lng: (-33.36879,-70.74436)",
"parametros6" =>"lat/lng: (-33.36882,-70.74415)",
"parametros7" =>"lat/lng: (-33.36888,-70.74387)",
"parametros8" =>"lat/lng: (-33.36905,-70.74364)",
"parametros9" =>"lat/lng: (-33.3691,-70.74347)",
"parametros10"=>"lat/lng: (-33.36948,-70.7417)"

And I want to store the values of Lat/lng in 2 arrays, how can I get the values separately ?

Ps:Sorry for my bad english,Thanks.-


This is gonna get a little convoluted, and thats cause some data processing is needed.

$lat = array(); 
$lon = array(); 

foreach($array as $k => $v){
 $v = str_replace('lat/lng: (','',$v);
 $v = str_replace(')','',$v);
 $v = explode(',', $v);
 $lat[] = $v[0];
 $lon[] = $v[1];