3v4l.org

run code in 300+ PHP versions simultaneously
<?php $response = '{ "results" : [ { "address_components" : [ { "long_name" : "277", "short_name" : "277", "types" : [ "street_number" ] }, { "long_name" : "Bedford Avenue", "short_name" : "Bedford Ave", "types" : [ "route" ] }, { "long_name" : "Williamsburg", "short_name" : "Williamsburg", "types" : [ "neighborhood", "political" ] }, { "long_name" : "Brooklyn", "short_name" : "Brooklyn", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "long_name" : "Kings County", "short_name" : "Kings County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] }, { "long_name" : "11211", "short_name" : "11211", "types" : [ "postal_code" ] } ], "formatted_address" : "277 Bedford Ave, Brooklyn, NY 11211, USA", "geometry" : { "location" : { "lat" : 40.714232, "lng" : -73.9612889 }, "location_type" : "ROOFTOP", "viewport" : { "northeast" : { "lat" : 40.7155809802915, "lng" : -73.9599399197085 }, "southwest" : { "lat" : 40.7128830197085, "lng" : -73.96263788029151 } } }, "place_id" : "ChIJd8BlQ2BZwokRAFUEcm_qrcA", "types" : [ "street_address" ] }, { "address_components" : [ { "long_name" : "Grand St/Bedford Av", "short_name" : "Grand St/Bedford Av", "types" : [ "point_of_interest", "establishment" ] }, { "long_name" : "Williamsburg", "short_name" : "Williamsburg", "types" : [ "neighborhood", "political" ] }, { "long_name" : "Brooklyn", "short_name" : "Brooklyn", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "long_name" : "Kings County", "short_name" : "Kings County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] }, { "long_name" : "11211", "short_name" : "11211", "types" : [ "postal_code" ] } ], "formatted_address" : "Grand St/Bedford Av, Brooklyn, NY 11211, USA", "geometry" : { "location" : { "lat" : 40.714321, "lng" : -73.961151 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 40.71566998029149, "lng" : -73.95980201970849 }, "southwest" : { "lat" : 40.7129720197085, "lng" : -73.96249998029151 } } }, "place_id" : "ChIJi27VXGBZwokRM8ErPyB91yk", "types" : [ "bus_station", "transit_station", "point_of_interest", "establishment" ] }, { "address_components" : [ { "long_name" : "Williamsburg", "short_name" : "Williamsburg", "types" : [ "neighborhood", "political" ] }, { "long_name" : "Brooklyn", "short_name" : "Brooklyn", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "long_name" : "New York", "short_name" : "New York", "types" : [ "locality", "political" ] }, { "long_name" : "Kings County", "short_name" : "Kings County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "Williamsburg, Brooklyn, NY, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 40.7251773, "lng" : -73.936498 }, "southwest" : { "lat" : 40.6979329, "lng" : -73.96984499999999 } }, "location" : { "lat" : 40.7081156, "lng" : -73.9570696 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 40.7251773, "lng" : -73.936498 }, "southwest" : { "lat" : 40.6979329, "lng" : -73.96984499999999 } } }, "place_id" : "ChIJQSrBBv1bwokRbNfFHCnyeYI", "types" : [ "neighborhood", "political" ] }, { "address_components" : [ { "long_name" : "Brooklyn", "short_name" : "Brooklyn", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "long_name" : "New York", "short_name" : "New York", "types" : [ "locality", "political" ] }, { "long_name" : "Kings County", "short_name" : "Kings County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "Brooklyn, NY, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 40.739446, "lng" : -73.83336509999999 }, "southwest" : { "lat" : 40.551042, "lng" : -74.05663 } }, "location" : { "lat" : 40.6781784, "lng" : -73.94415789999999 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 40.739446, "lng" : -73.83336509999999 }, "southwest" : { "lat" : 40.551042, "lng" : -74.05663 } } }, "place_id" : "ChIJCSF8lBZEwokRhngABHRcdoI", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "address_components" : [ { "long_name" : "New York", "short_name" : "New York", "types" : [ "locality", "political" ] }, { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "New York, NY, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 40.91525559999999, "lng" : -73.70027209999999 }, "southwest" : { "lat" : 40.4960439, "lng" : -74.25573489999999 } }, "location" : { "lat" : 40.7127837, "lng" : -74.0059413 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 40.91525559999999, "lng" : -73.70027209999999 }, "southwest" : { "lat" : 40.4960439, "lng" : -74.25573489999999 } } }, "place_id" : "ChIJOwg_06VPwokRYv534QaPC8g", "types" : [ "locality", "political" ] }, { "address_components" : [ { "long_name" : "11211", "short_name" : "11211", "types" : [ "postal_code" ] }, { "long_name" : "Brooklyn", "short_name" : "Brooklyn", "types" : [ "sublocality_level_1", "sublocality", "political" ] }, { "long_name" : "New York", "short_name" : "New York", "types" : [ "locality", "political" ] }, { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "Brooklyn, NY 11211, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 40.7280089, "lng" : -73.9207299 }, "southwest" : { "lat" : 40.7008331, "lng" : -73.9644697 } }, "location" : { "lat" : 40.7093358, "lng" : -73.9565551 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 40.7280089, "lng" : -73.9207299 }, "southwest" : { "lat" : 40.7008331, "lng" : -73.9644697 } } }, "place_id" : "ChIJvbEjlVdZwokR4KapM3WCFRw", "types" : [ "postal_code" ] }, { "address_components" : [ { "long_name" : "Kings County", "short_name" : "Kings County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "Kings County, NY, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 40.7391407, "lng" : -73.83336509999999 }, "southwest" : { "lat" : 40.5702197, "lng" : -74.04195919999999 } }, "location" : { "lat" : 40.6528762, "lng" : -73.95949399999999 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 40.7391407, "lng" : -73.83336509999999 }, "southwest" : { "lat" : 40.5702197, "lng" : -74.04195919999999 } } }, "place_id" : "ChIJOwE7_GTtwokRs75rhW4_I6M", "types" : [ "administrative_area_level_2", "political" ] }, { "address_components" : [ { "long_name" : "New York", "short_name" : "NY", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "New York, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 45.015865, "lng" : -71.8562293 }, "southwest" : { "lat" : 40.496091, "lng" : -79.76214379999999 } }, "location" : { "lat" : 43.2994285, "lng" : -74.21793260000001 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 45.015859, "lng" : -71.8562293 }, "southwest" : { "lat" : 40.496091, "lng" : -79.76214379999999 } } }, "place_id" : "ChIJqaUj8fBLzEwRZ5UY3sHGz90", "types" : [ "administrative_area_level_1", "political" ] }, { "address_components" : [ { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "United States", "geometry" : { "bounds" : { "northeast" : { "lat" : 71.3867745, "lng" : -66.9502861 }, "southwest" : { "lat" : 18.9106768, "lng" : 172.4458955 } }, "location" : { "lat" : 37.09024, "lng" : -95.712891 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 49.38, "lng" : -66.94 }, "southwest" : { "lat" : 25.82, "lng" : -124.39 } } }, "place_id" : "ChIJCzYy5IS16lQRQrfeQ5K5Oxw", "types" : [ "country", "political" ] } ], "status" : "OK" }'; $array = json_decode($response, TRUE); $iterator = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($array), \RecursiveIteratorIterator::SELF_FIRST); // Recurse through the result array. When there is an array of items at the // expected depth that has the expected identifier as one of the keys, pull that // array out as a distinct item. $identifier = 'place_id'; $identifierDepth = 1; $items = []; while ($iterator->valid()) { $iterator->next(); $item = $iterator->current(); // Segfaults on last row from gmap data. if (is_array($item)) { if (array_key_exists($identifier, $item)) { if ( $iterator->getDepth() == $identifierDepth) { $items[] = $item; } } } } echo 'no error';
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.1.20, 7.2.29 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
no error
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 no error
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.6

Process exited with code 139.

preferences:
164.53 ms | 402 KiB | 183 Q