3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<EOT { "results" : [ { "address_components" : [ { "long_name" : "Winnetka", "short_name" : "Winnetka", "types" : [ "locality", "political" ] }, { "long_name" : "New Trier", "short_name" : "New Trier", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Cook County", "short_name" : "Cook County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Illinois", "short_name" : "IL", "types" : [ "administrative_area_level_1", "political"] }, { "long_name" : "Switzerland", "short_name" : "CH", "types" : [ "country", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "Winnetka, IL, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 42.1282269, "lng" : -87.7108162 }, "southwest" : { "lat" : 42.0886089, "lng" : -87.7708629 } }, "location" : { "lat" : 42.10808340000001, "lng" : -87.735895 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 42.1282269, "lng" : -87.7108162 }, "southwest" : { "lat" : 42.0886089, "lng" : -87.7708629 } } }, "place_id" : "ChIJW8Va5TnED4gRY91Ng47qy3Q", "types" : [ "locality", "political" ] }, { "address_components" : [ { "long_name" : "Winnetka", "short_name" : "Winnetka", "types" : [ "locality", "political" ] }, { "long_name" : "New Trier", "short_name" : "New Trier", "types" : [ "administrative_area_level_3", "political" ] }, { "long_name" : "Cook County", "short_name" : "Cook County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "Illinois", "short_name" : "IL", "types" : [ "administrative_area_level_1", "political"] }, { "long_name" : "United States - 2", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "Winnetka, IL, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 42.1282269, "lng" : -87.7108162 }, "southwest" : { "lat" : 42.0886089, "lng" : -87.7708629 } }, "location" : { "lat" : 42.10808340000001, "lng" : -87.735895 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 42.1282269, "lng" : -87.7108162 }, "southwest" : { "lat" : 42.0886089, "lng" : -87.7708629 } } }, "place_id" : "ChIJW8Va5TnED4gRY91Ng47qy3Q", "types" : [ "locality", "political" ] } ], "status" : "OK" } EOT; $data = json_decode($json); $counties = []; foreach($data->results as $result){ $counties = array_merge($counties, array_filter($result->address_components, function ($address) { return in_array('administrative_area_level_2', $address->types); })); } $counties = array_map(function ($county) { return $county->long_name; }, $counties); echo implode(', ', $counties);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 21
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 21
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/UUboK
function name:  (null)
number of ops:  34
compiled vars:  !0 = $json, !1 = $data, !2 = $counties, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22results%22+%3A+%5B%0A++++++%7B%0A+++++++++%22address_components%22+%3A+%5B%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22Winnetka%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22Winnetka%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22locality%22%2C+%22political%22+%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22New+Trier%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22New+Trier%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22administrative_area_level_3%22%2C+%22political%22+%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22Cook+County%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22Cook+County%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22administrative_area_level_2%22%2C+%22political%22+%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22Illinois%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22IL%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22administrative_area_level_1%22%2C+%22political%22%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22Switzerland%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22CH%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22country%22%2C+%22political%22+%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22United+States%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22US%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22country%22%2C+%22political%22+%5D%0A++++++++++++%7D%0A+++++++++%5D%2C%0A+++++++++%22formatted_address%22+%3A+%22Winnetka%2C+IL%2C+USA%22%2C%0A+++++++++%22geometry%22+%3A+%7B%0A++++++++++++%22bounds%22+%3A+%7B%0A+++++++++++++++%22northeast%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.1282269%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7108162%0A+++++++++++++++%7D%2C%0A+++++++++++++++%22southwest%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.0886089%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7708629%0A+++++++++++++++%7D%0A++++++++++++%7D%2C%0A++++++++++++%22location%22+%3A+%7B%0A+++++++++++++++%22lat%22+%3A+42.10808340000001%2C%0A+++++++++++++++%22lng%22+%3A+-87.735895%0A++++++++++++%7D%2C%0A++++++++++++%22location_type%22+%3A+%22APPROXIMATE%22%2C%0A++++++++++++%22viewport%22+%3A+%7B%0A+++++++++++++++%22northeast%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.1282269%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7108162%0A+++++++++++++++%7D%2C%0A+++++++++++++++%22southwest%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.0886089%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7708629%0A+++++++++++++++%7D%0A++++++++++++%7D%0A+++++++++%7D%2C%0A+++++++++%22place_id%22+%3A+%22ChIJW8Va5TnED4gRY91Ng47qy3Q%22%2C%0A+++++++++%22types%22+%3A+%5B+%22locality%22%2C+%22political%22+%5D%0A++++++%7D%2C%0A+++++++%7B%0A+++++++++%22address_components%22+%3A+%5B%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22Winnetka%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22Winnetka%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22locality%22%2C+%22political%22+%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22New+Trier%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22New+Trier%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22administrative_area_level_3%22%2C+%22political%22+%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22Cook+County%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22Cook+County%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22administrative_area_level_2%22%2C+%22political%22+%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22Illinois%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22IL%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22administrative_area_level_1%22%2C+%22political%22%5D%0A++++++++++++%7D%2C%0A++++++++++++%7B%0A+++++++++++++++%22long_name%22+%3A+%22United+States+-+2%22%2C%0A+++++++++++++++%22short_name%22+%3A+%22US%22%2C%0A+++++++++++++++%22types%22+%3A+%5B+%22country%22%2C+%22political%22+%5D%0A++++++++++++%7D%0A+++++++++%5D%2C%0A+++++++++%22formatted_address%22+%3A+%22Winnetka%2C+IL%2C+USA%22%2C%0A+++++++++%22geometry%22+%3A+%7B%0A++++++++++++%22bounds%22+%3A+%7B%0A+++++++++++++++%22northeast%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.1282269%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7108162%0A+++++++++++++++%7D%2C%0A+++++++++++++++%22southwest%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.0886089%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7708629%0A+++++++++++++++%7D%0A++++++++++++%7D%2C%0A++++++++++++%22location%22+%3A+%7B%0A+++++++++++++++%22lat%22+%3A+42.10808340000001%2C%0A+++++++++++++++%22lng%22+%3A+-87.735895%0A++++++++++++%7D%2C%0A++++++++++++%22location_type%22+%3A+%22APPROXIMATE%22%2C%0A++++++++++++%22viewport%22+%3A+%7B%0A+++++++++++++++%22northeast%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.1282269%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7108162%0A+++++++++++++++%7D%2C%0A+++++++++++++++%22southwest%22+%3A+%7B%0A++++++++++++++++++%22lat%22+%3A+42.0886089%2C%0A++++++++++++++++++%22lng%22+%3A+-87.7708629%0A+++++++++++++++%7D%0A++++++++++++%7D%0A+++++++++%7D%2C%0A+++++++++%22place_id%22+%3A+%22ChIJW8Va5TnED4gRY91Ng47qy3Q%22%2C%0A+++++++++%22types%22+%3A+%5B+%22locality%22%2C+%22political%22+%5D%0A++++++%7D%0A+++%5D%2C%0A+++%22status%22+%3A+%22OK%22%0A%7D+'
  135     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !1, $5
  137     5        ASSIGN                                                   !2, <array>
  139     6        FETCH_OBJ_R                                      ~8      !1, 'results'
          7      > FE_RESET_R                                       $9      ~8, ->21
          8    > > FE_FETCH_R                                               $9, !3, ->21
  140     9    >   INIT_FCALL                                               'array_merge'
         10        SEND_VAR                                                 !2
         11        INIT_FCALL                                               'array_filter'
         12        FETCH_OBJ_R                                      ~10     !3, 'address_components'
         13        SEND_VAL                                                 ~10
         14        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
  142    15        SEND_VAL                                                 ~11
  140    16        DO_ICALL                                         $12     
  142    17        SEND_VAR                                                 $12
  140    18        DO_ICALL                                         $13     
         19        ASSIGN                                                   !2, $13
  139    20      > JMP                                                      ->8
         21    >   FE_FREE                                                  $9
  146    22        INIT_FCALL                                               'array_map'
         23        DECLARE_LAMBDA_FUNCTION                          ~15     [1]
  148    24        SEND_VAL                                                 ~15
         25        SEND_VAR                                                 !2
  146    26        DO_ICALL                                         $16     
         27        ASSIGN                                                   !2, $16
  151    28        INIT_FCALL                                               'implode'
         29        SEND_VAL                                                 '%2C+'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                         $18     
         32        ECHO                                                     $18
         33      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UUboK
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $address
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  140     0  E >   RECV                                             !0      
  141     1        INIT_FCALL                                               'in_array'
          2        SEND_VAL                                                 'administrative_area_level_2'
          3        FETCH_OBJ_R                                      ~1      !0, 'types'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
  142     7*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UUboK
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $county
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  146     0  E >   RECV                                             !0      
  147     1        FETCH_OBJ_R                                      ~1      !0, 'long_name'
          2      > RETURN                                                   ~1
  148     3*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.76 ms | 1014 KiB | 19 Q