@ 2017-07-08T21:47:33Z <?php
$json = '{
"results" : [
{
"address_components" : [
{
"long_name" : "P9/10",
"short_name" : "P9/10",
"types" : [ "premise" ]
},
{
"long_name" : "Pochanpur Colony",
"short_name" : "Pochanpur Colony",
"types" : [ "political", "sublocality", "sublocality_level_2" ]
},
{
"long_name" : "Dwarka",
"short_name" : "Dwarka",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"long_name" : "Delhi",
"short_name" : "Delhi",
"types" : [ "locality", "political" ]
},
{
"long_name" : "South West Delhi",
"short_name" : "South West Delhi",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
},
{
"long_name" : "110075",
"short_name" : "110075",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "P9/10, Pochanpur Colony, Dwarka, Delhi, 110075, India",
"geometry" : {
"location" : {
"lat" : 28.563945,
"lng" : 77.04248679999999
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 28.5652939802915,
"lng" : 77.0438357802915
},
"southwest" : {
"lat" : 28.5625960197085,
"lng" : 77.0411378197085
}
}
},
"place_id" : "ChIJ0zkWBPcaDTkR8OpAXK17Qp8",
"types" : [ "street_address" ]
},
{
"address_components" : [
{
"long_name" : "Pocket 8",
"short_name" : "Pocket 8",
"types" : [ "establishment", "point_of_interest" ]
},
{
"long_name" : "Kala Ata Chakki",
"short_name" : "Kala Ata Chakki",
"types" : [ "route" ]
},
{
"long_name" : "Dhul Siras",
"short_name" : "Dhul Siras",
"types" : [ "political", "sublocality", "sublocality_level_2" ]
},
{
"long_name" : "Dwarka",
"short_name" : "Dwarka",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"long_name" : "Delhi",
"short_name" : "Delhi",
"types" : [ "locality", "political" ]
},
{
"long_name" : "South West Delhi",
"short_name" : "South West Delhi",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
},
{
"long_name" : "110075",
"short_name" : "110075",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "Pocket 8, Dwarka Sector 23 B, Kala Ata Chakki, Dhul Siras, Dwarka, Delhi, 110075, India",
"geometry" : {
"location" : {
"lat" : 28.5628438,
"lng" : 77.0427552
},
"location_type" : "GEOMETRIC_CENTER",
"viewport" : {
"northeast" : {
"lat" : 28.5641927802915,
"lng" : 77.04410418029151
},
"southwest" : {
"lat" : 28.5614948197085,
"lng" : 77.04140621970849
}
}
},
"place_id" : "ChIJnYkGsPcaDTkRYBzk95MrbgM",
"types" : [ "establishment", "point_of_interest" ]
},
{
"address_components" : [
{
"long_name" : "Dhul Siras",
"short_name" : "Dhul Siras",
"types" : [ "political", "sublocality", "sublocality_level_2" ]
},
{
"long_name" : "Dwarka",
"short_name" : "Dwarka",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"long_name" : "Delhi",
"short_name" : "Delhi",
"types" : [ "locality", "political" ]
},
{
"long_name" : "South West Delhi",
"short_name" : "South West Delhi",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Dhul Siras, Dwarka, Delhi, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 28.5667969,
"lng" : 77.04649479999999
},
"southwest" : {
"lat" : 28.551814,
"lng" : 77.0272779
}
},
"location" : {
"lat" : 28.5641729,
"lng" : 77.0413344
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 28.5667969,
"lng" : 77.04649479999999
},
"southwest" : {
"lat" : 28.561422,
"lng" : 77.03926439999999
}
}
},
"place_id" : "ChIJhSDHK2EaDTkRETqqvXgJpaY",
"types" : [ "political", "sublocality", "sublocality_level_2" ]
},
{
"address_components" : [
{
"long_name" : "Dwarka",
"short_name" : "Dwarka",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"long_name" : "New Delhi",
"short_name" : "New Delhi",
"types" : [ "locality", "political" ]
},
{
"long_name" : "South West Delhi",
"short_name" : "South West Delhi",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Dwarka, New Delhi, Delhi, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 28.6208451,
"lng" : 77.0851753
},
"southwest" : {
"lat" : 28.5257751,
"lng" : 77.00929099999999
}
},
"location" : {
"lat" : 28.5921401,
"lng" : 77.04604809999999
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 28.6208451,
"lng" : 77.0851753
},
"southwest" : {
"lat" : 28.5257751,
"lng" : 77.00929099999999
}
}
},
"place_id" : "ChIJ4cTuMZwaDTkRmsiky3Y5STk",
"types" : [ "political", "sublocality", "sublocality_level_1" ]
},
{
"address_components" : [
{
"long_name" : "Delhi",
"short_name" : "Delhi",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Delhi, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 28.88284,
"lng" : 77.34488
},
"southwest" : {
"lat" : 28.50197,
"lng" : 76.8378199
}
},
"location" : {
"lat" : 28.6618976,
"lng" : 77.2273958
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 28.88284,
"lng" : 77.34488
},
"southwest" : {
"lat" : 28.50197,
"lng" : 76.8378199
}
}
},
"place_id" : "ChIJL_P_CXMEDTkRw0ZdG-0GVvw",
"types" : [ "locality", "political" ]
},
{
"address_components" : [
{
"long_name" : "110075",
"short_name" : "110075",
"types" : [ "postal_code" ]
},
{
"long_name" : "New Delhi",
"short_name" : "New Delhi",
"types" : [ "locality", "political" ]
},
{
"long_name" : "South West Delhi",
"short_name" : "South West Delhi",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "New Delhi, Delhi 110075, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 28.6062045,
"lng" : 77.07717749999999
},
"southwest" : {
"lat" : 28.5547049,
"lng" : 77.0103792
}
},
"location" : {
"lat" : 28.5899848,
"lng" : 77.0443796
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 28.6062045,
"lng" : 77.07717749999999
},
"southwest" : {
"lat" : 28.5547049,
"lng" : 77.0103792
}
}
},
"place_id" : "ChIJY690SeQaDTkRDlww_BqyZd8",
"types" : [ "postal_code" ]
},
{
"address_components" : [
{
"long_name" : "South West Delhi",
"short_name" : "South West Delhi",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "South West Delhi, Delhi, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 28.67243,
"lng" : 77.10914989999999
},
"southwest" : {
"lat" : 28.50197,
"lng" : 76.8378199
}
},
"location" : {
"lat" : 28.5928929,
"lng" : 77.03461639999999
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 28.67243,
"lng" : 77.10914989999999
},
"southwest" : {
"lat" : 28.50197,
"lng" : 76.8378199
}
}
},
"place_id" : "ChIJxbsO85oaDTkRGDJ4ocUr_Qw",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"address_components" : [
{
"long_name" : "Delhi",
"short_name" : "DL",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "Delhi, India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 28.881338,
"lng" : 77.34845780000001
},
"southwest" : {
"lat" : 28.412593,
"lng" : 76.83806899999999
}
},
"location" : {
"lat" : 28.7040592,
"lng" : 77.10249019999999
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 28.881338,
"lng" : 77.34845780000001
},
"southwest" : {
"lat" : 28.412593,
"lng" : 76.83806899999999
}
}
},
"place_id" : "ChIJLbZ-NFv9DDkRQJY4FbcFcgM",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"address_components" : [
{
"long_name" : "India",
"short_name" : "IN",
"types" : [ "country", "political" ]
}
],
"formatted_address" : "India",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 35.5087008,
"lng" : 97.39535869999999
},
"southwest" : {
"lat" : 6.4626999,
"lng" : 68.1097
}
},
"location" : {
"lat" : 20.593684,
"lng" : 78.96288
},
"location_type" : "APPROXIMATE",
"viewport" : {
"northeast" : {
"lat" : 35.5087008,
"lng" : 97.39498069999999
},
"southwest" : {
"lat" : 6.7535159,
"lng" : 68.16288519999999
}
}
},
"place_id" : "ChIJkbeSa_BfYzARphNChaFPjNc",
"types" : [ "country", "political" ]
}
],
"status" : "OK"
}';
function getAddress($elements){
$addr = [];
foreach($elements as $e){
if(isset($e['types']) && in_array("street_number",$e['types'])) $addr['street_number'] = $e['long_name'];
if(isset($e['types']) && in_array("street_number",$e['types'])) $addr['route'] = $e['long_name'];
if(isset($e['types']) && in_array("administrative_area_level_2",$e['types'])) $addr['city'] = $e['long_name'];
}
return $addr;
}
$obj = json_decode($json, true);
$c = $obj['results'][0]['address_components'];
var_dump(getAddress($c));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.018 0.003 16.50 8.3.5 0.007 0.007 16.46 8.3.4 0.018 0.004 18.83 8.3.3 0.009 0.006 18.64 8.3.2 0.010 0.003 20.27 8.3.1 0.009 0.000 22.02 8.3.0 0.006 0.003 17.90 8.2.18 0.000 0.014 18.41 8.2.17 0.009 0.006 22.96 8.2.16 0.003 0.010 20.47 8.2.15 0.004 0.004 24.18 8.2.14 0.000 0.008 24.66 8.2.13 0.004 0.004 21.04 8.2.12 0.004 0.004 26.35 8.2.11 0.006 0.003 22.16 8.2.10 0.004 0.007 18.34 8.2.9 0.004 0.004 19.38 8.2.8 0.004 0.004 18.16 8.2.7 0.003 0.006 17.88 8.2.6 0.000 0.010 18.12 8.2.5 0.004 0.004 18.18 8.2.4 0.003 0.005 20.55 8.2.3 0.004 0.004 19.36 8.2.2 0.005 0.003 18.34 8.2.1 0.006 0.003 18.23 8.2.0 0.004 0.004 18.23 8.1.28 0.013 0.003 25.92 8.1.27 0.009 0.000 23.99 8.1.26 0.004 0.004 26.35 8.1.25 0.007 0.000 28.09 8.1.24 0.010 0.000 20.73 8.1.23 0.012 0.000 17.50 8.1.22 0.006 0.003 17.77 8.1.21 0.003 0.005 18.77 8.1.20 0.003 0.006 17.38 8.1.19 0.004 0.004 17.47 8.1.18 0.004 0.004 18.10 8.1.17 0.006 0.003 18.80 8.1.16 0.004 0.004 19.14 8.1.15 0.004 0.004 20.68 8.1.14 0.002 0.005 19.58 8.1.13 0.003 0.007 18.92 8.1.12 0.000 0.007 17.60 8.1.11 0.003 0.006 17.47 8.1.10 0.003 0.006 17.64 8.1.9 0.004 0.004 17.61 8.1.8 0.000 0.007 17.48 8.1.7 0.004 0.004 17.47 8.1.6 0.004 0.004 17.70 8.1.5 0.008 0.000 17.61 8.1.4 0.004 0.004 17.65 8.1.3 0.004 0.004 17.81 8.1.2 0.003 0.005 17.70 8.1.1 0.000 0.008 17.63 8.1.0 0.006 0.003 17.61 8.0.30 0.000 0.008 18.77 8.0.29 0.003 0.005 16.88 8.0.28 0.000 0.007 18.48 8.0.27 0.004 0.004 17.40 8.0.26 0.000 0.007 16.80 8.0.25 0.000 0.007 17.11 8.0.24 0.000 0.007 17.04 8.0.23 0.000 0.008 17.04 8.0.22 0.003 0.003 16.88 8.0.21 0.003 0.003 17.00 8.0.20 0.003 0.003 16.95 8.0.19 0.006 0.003 17.12 8.0.18 0.004 0.007 16.91 8.0.17 0.000 0.007 17.02 8.0.16 0.005 0.003 17.01 8.0.15 0.000 0.008 16.88 8.0.14 0.000 0.007 16.96 8.0.13 0.000 0.006 13.43 8.0.12 0.000 0.007 16.87 8.0.11 0.004 0.004 16.93 8.0.10 0.005 0.002 16.99 8.0.9 0.005 0.002 17.00 8.0.8 0.000 0.016 17.03 8.0.7 0.004 0.004 16.82 8.0.6 0.000 0.008 16.82 8.0.5 0.000 0.008 16.90 8.0.3 0.010 0.008 17.26 8.0.2 0.012 0.007 17.40 8.0.1 0.007 0.000 17.05 8.0.0 0.004 0.013 16.77 7.4.33 0.005 0.000 15.55 7.4.32 0.000 0.007 16.62 7.4.30 0.004 0.004 16.73 7.4.29 0.003 0.005 16.70 7.4.28 0.005 0.003 16.61 7.4.27 0.007 0.000 16.61 7.4.26 0.000 0.008 13.38 7.4.25 0.003 0.004 16.55 7.4.24 0.004 0.004 16.57 7.4.23 0.004 0.004 16.66 7.4.22 0.004 0.015 16.65 7.4.21 0.013 0.006 16.65 7.4.20 0.005 0.003 16.50 7.4.16 0.006 0.009 16.63 7.4.15 0.009 0.009 17.40 7.4.14 0.011 0.009 17.86 7.4.13 0.012 0.010 16.55 7.4.12 0.010 0.010 16.59 7.4.11 0.017 0.000 16.53 7.4.10 0.003 0.017 16.53 7.4.9 0.006 0.011 16.82 7.4.8 0.011 0.009 19.39 7.4.7 0.003 0.013 16.65 7.4.6 0.004 0.012 16.73 7.4.5 0.013 0.003 16.52 7.4.4 0.007 0.010 16.38 7.4.3 0.010 0.007 16.72 7.4.0 0.007 0.010 15.22 7.3.33 0.003 0.003 13.35 7.3.32 0.000 0.005 13.41 7.3.31 0.004 0.004 16.37 7.3.30 0.000 0.007 16.47 7.3.29 0.003 0.006 16.47 7.3.28 0.008 0.007 16.46 7.3.27 0.014 0.011 17.40 7.3.26 0.015 0.007 16.68 7.3.25 0.012 0.009 16.56 7.3.24 0.006 0.011 16.50 7.3.23 0.012 0.007 16.49 7.3.21 0.006 0.012 16.57 7.3.20 0.008 0.008 16.62 7.3.19 0.009 0.009 16.61 7.3.18 0.011 0.006 16.59 7.3.17 0.007 0.010 16.61 7.3.16 0.016 0.000 16.67 7.3.1 0.005 0.008 16.52 7.3.0 0.004 0.007 16.48 7.2.33 0.015 0.003 16.56 7.2.32 0.000 0.016 16.84 7.2.31 0.014 0.010 16.61 7.2.30 0.009 0.015 16.68 7.2.29 0.013 0.003 16.85 7.2.13 0.004 0.009 16.82 7.2.12 0.011 0.003 16.83 7.2.11 0.007 0.005 16.94 7.2.10 0.004 0.011 16.68 7.2.9 0.004 0.010 16.81 7.2.8 0.008 0.010 16.64 7.2.7 0.002 0.008 17.01 7.2.6 0.008 0.008 16.91 7.2.5 0.006 0.008 16.79 7.2.4 0.008 0.005 16.89 7.2.3 0.007 0.009 16.64 7.2.2 0.007 0.008 16.93 7.2.1 0.007 0.006 16.82 7.2.0 0.006 0.007 17.46 7.1.25 0.010 0.005 15.86 7.1.24 0.010 0.006 15.90 7.1.23 0.009 0.009 15.84 7.1.22 0.000 0.008 15.95 7.1.21 0.000 0.010 15.84 7.1.20 0.007 0.005 15.70 7.1.19 0.000 0.014 15.88 7.1.18 0.003 0.010 15.94 7.1.17 0.010 0.003 15.89 7.1.16 0.000 0.008 15.63 7.1.15 0.000 0.010 15.82 7.1.14 0.007 0.007 15.73 7.1.13 0.004 0.008 15.83 7.1.12 0.011 0.004 15.98 7.1.11 0.003 0.007 15.73 7.1.10 0.005 0.009 16.85 7.1.9 0.007 0.003 15.67 7.1.8 0.007 0.003 15.93 7.1.7 0.002 0.007 16.31 7.1.6 0.004 0.007 16.63 7.1.5 0.013 0.003 16.37 7.1.4 0.004 0.009 16.13 7.1.3 0.005 0.007 16.21 7.1.2 0.006 0.006 16.34 7.1.1 0.005 0.006 16.03 7.1.0 0.001 0.008 16.32 7.0.33 0.010 0.003 15.31 7.0.32 0.006 0.003 15.47 7.0.31 0.003 0.009 15.30 7.0.30 0.003 0.010 15.30 7.0.29 0.006 0.006 15.29 7.0.28 0.009 0.003 15.36 7.0.27 0.006 0.003 15.51 7.0.26 0.004 0.004 15.33 7.0.25 0.003 0.006 15.56 7.0.24 0.007 0.007 15.52 7.0.23 0.003 0.009 15.46 7.0.22 0.003 0.010 15.05 7.0.21 0.003 0.007 15.30 7.0.20 0.006 0.002 16.06 7.0.19 0.007 0.003 16.08 7.0.18 0.003 0.007 15.75 7.0.17 0.005 0.006 15.81 7.0.16 0.002 0.008 15.68 7.0.15 0.003 0.005 15.89 7.0.14 0.008 0.005 15.94 7.0.13 0.002 0.008 16.07 7.0.12 0.006 0.003 16.02 7.0.11 0.008 0.007 16.10 7.0.10 0.003 0.006 15.88 7.0.9 0.006 0.002 15.72 7.0.8 0.003 0.008 15.80 7.0.7 0.004 0.005 15.99 7.0.6 0.005 0.004 15.77 7.0.5 0.002 0.011 15.94 7.0.4 0.004 0.007 14.15 7.0.3 0.005 0.006 14.08 7.0.2 0.002 0.007 14.15 7.0.1 0.006 0.009 14.23 7.0.0 0.004 0.009 14.21 5.6.38 0.003 0.010 14.35
preferences:dark mode live preview
30.59 ms | 401 KiB | 5 Q