3v4l.org

run code in 500+ 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 = []; if(!empty($data->results)){ $counties = array_filter($data->results[0]->address_components, function ($address) { return in_array('administrative_area_level_2', $address->types); }); } if(!empty($counties)){ echo reset($counties)->long_name; }else{ echo 'No county found'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/5RGOe
function name:  (null)
number of ops:  29
compiled vars:  !0 = $json, !1 = $data, !2 = $counties
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                                             $4      
          4        ASSIGN                                                       !1, $4
  136     5        ASSIGN                                                       !2, <array>
  138     6        ISSET_ISEMPTY_PROP_OBJ                               ~7      !1, 'results'
          7        BOOL_NOT                                             ~8      ~7
          8      > JMPZ                                                         ~8, ->18
  139     9    >   INIT_FCALL                                                   'array_filter'
         10        FETCH_OBJ_R                                          ~9      !1, 'results'
         11        FETCH_DIM_R                                          ~10     ~9, 0
         12        FETCH_OBJ_R                                          ~11     ~10, 'address_components'
         13        SEND_VAL                                                     ~11
         14        DECLARE_LAMBDA_FUNCTION                              ~12     [0]
  141    15        SEND_VAL                                                     ~12
  139    16        DO_ICALL                                             $13     
         17        ASSIGN                                                       !2, $13
  145    18    >   ISSET_ISEMPTY_CV                                     ~15     !2
         19        BOOL_NOT                                             ~16     ~15
         20      > JMPZ                                                         ~16, ->27
  146    21    >   INIT_FCALL                                                   'reset'
         22        SEND_REF                                                     !2
         23        DO_ICALL                                             $17     
         24        FETCH_OBJ_R                                          ~18     $17, 'long_name'
         25        ECHO                                                         ~18
  145    26      > JMP                                                          ->28
  148    27    >   ECHO                                                         'No+county+found'
  149    28    > > 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/5RGOe
function name:  {closure:/in/5RGOe:139}
number of ops:  5
compiled vars:  !0 = $address
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  139     0  E >   RECV                                                 !0      
  140     1        FETCH_OBJ_R                                          ~1      !0, 'types'
          2        FRAMELESS_ICALL_2                in_array            ~2      'administrative_area_level_2', ~1
          3      > RETURN                                                       ~2
  141     4*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.76 ms | 1979 KiB | 16 Q