Using actionscript3 Syntax Highlighting
<?php header('Content-Type: text/html; UTF-8');
$post_code = $_GET['pc'];
$post_code = "usa";
$post_code = trim($post_code);
//$post_code = str_replace("%20",",",$post_code);
//$post_code = utf8_urldecode($post_code);
if($post_code != NULL)
{
$location = "http://maps.googleapis.com/maps/api/geocode/json?address=".$post_code."&sensor=true";
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, $location);
curl_setopt($ch , CURLOPT_HEADER, 0);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
//$result3 = new SimpleXMLElement($result);//json_decode($result);
//echo $result3."<br>"."<br>";
echo $result;
//data.results[0].geometry.location.lat;
}
function utf8_urldecode($str)
{
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
return html_entity_decode($str,null,'UTF-8');
}
?>
$post_code = $_GET['pc'];
$post_code = "usa";
$post_code = trim($post_code);
//$post_code = str_replace("%20",",",$post_code);
//$post_code = utf8_urldecode($post_code);
if($post_code != NULL)
{
$location = "http://maps.googleapis.com/maps/api/geocode/json?address=".$post_code."&sensor=true";
$ch = curl_init();
curl_setopt($ch , CURLOPT_URL, $location);
curl_setopt($ch , CURLOPT_HEADER, 0);
curl_setopt($ch , CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
//$result3 = new SimpleXMLElement($result);//json_decode($result);
//echo $result3."<br>"."<br>";
echo $result;
//data.results[0].geometry.location.lat;
}
function utf8_urldecode($str)
{
$str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
return html_entity_decode($str,null,'UTF-8');
}
?>
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
ובעצם שאני עושה ECHO ל RESULT זה מה שאני מקבל
Using actionscript3 Syntax Highlighting
{ "results" : [ { "address_components" : [ { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "United States", "geometry" : { "bounds" : { "northeast" : { "lat" : 71.3898880, "lng" : -66.94539480000002 }, "southwest" : { "lat" : 18.91106430, "lng" : 172.45469670 } }, "location" : { "lat" : 37.090240, "lng" : -95.7128910 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 64.73664149999999, "lng" : -30.14648320 }, "southwest" : { "lat" : -5.70344770, "lng" : -161.27929880 } } }, "types" : [ "country", "political" ] } ], "status" : "OK" }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
למשהו מושג איך דרך המשתנה של RESULT אני פונה נניח ל LAT שב LOCATION
ב JS הגעתי ככה:
data.results[0].geometry.location.lat;
וב PHP נסיתי ככה:
Using actionscript3 Syntax Highlighting
אך זה לא פועל אני אשמח לדעת אם למשהו יש איזה רעיון איך אני עושה את זה
חדשות