3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{ "data": [ { "sentenceArray": [ { "path": { "type": "walk", "nodes": [ { "lat": 39.952614, "lng": 32.854491 }, { "lat": 39.952083, "lng": 32.857761 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.952418, "lng": 32.85727 }, { "lat": 39.952797, "lng": 32.856825 }, { "lat": 39.953102, "lng": 32.856438 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.964951, "lng": 32.841305 }, { "lat": 39.964785, "lng": 32.841514 } ] } } ] }, { "sentenceArray": [ { "path": { "type": "walk", "nodes": [ { "lat": 39.952614, "lng": 32.854491 }, { "lat": 39.952083, "lng": 32.857761 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.952418, "lng": 32.85727 }, { "lat": 39.952797, "lng": 32.856825 }, { "lat": 39.953102, "lng": 32.856438 } ] } }, { "path": { "type": "bus", "nodes": [ { "lat": 39.964951, "lng": 32.841305 }, { "lat": 39.964785, "lng": 32.841514 } ] } } ] } ] }'; $array = json_decode($json, true); foreach ($array['data'] as $datas) { foreach ($datas['sentenceArray'] as $subitem) { if ($subitem['path']['type'] == 'bus' && isset($subitem['path']['nodes'])) { $result[] = $subitem['path']['nodes']; } } } echo json_encode($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 24
Branch analysis from position: 19
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/89bf8
function name:  (null)
number of ops:  33
compiled vars:  !0 = $json, !1 = $array, !2 = $datas, !3 = $subitem, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%7B%0A++%22data%22%3A+%5B%0A++++%7B%0A++++++%22sentenceArray%22%3A+%5B%0A++++++++%7B%0A++++++++++%22path%22%3A+%7B%0A++++++++++++%22type%22%3A+%22walk%22%2C%0A++++++++++++%22nodes%22%3A+%5B%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952614%2C%0A++++++++++++++++%22lng%22%3A+32.854491%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952083%2C%0A++++++++++++++++%22lng%22%3A+32.857761%0A++++++++++++++%7D%0A++++++++++++%5D%0A++++++++++%7D%0A++++++++%7D%2C%0A++++++++%7B%0A++++++++++%22path%22%3A+%7B%0A++++++++++++%22type%22%3A+%22bus%22%2C%0A++++++++++++%22nodes%22%3A+%5B%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952418%2C%0A++++++++++++++++%22lng%22%3A+32.85727%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952797%2C%0A++++++++++++++++%22lng%22%3A+32.856825%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.953102%2C%0A++++++++++++++++%22lng%22%3A+32.856438%0A++++++++++++++%7D%0A++++++++++++%5D%0A++++++++++%7D%0A++++++++%7D%2C%0A++++++++%7B%0A++++++++++%22path%22%3A+%7B%0A++++++++++++%22type%22%3A+%22bus%22%2C%0A++++++++++++%22nodes%22%3A+%5B%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.964951%2C%0A++++++++++++++++%22lng%22%3A+32.841305%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.964785%2C%0A++++++++++++++++%22lng%22%3A+32.841514%0A++++++++++++++%7D%0A++++++++++++%5D%0A++++++++++%7D%0A++++++++%7D%0A++++++%5D%0A++++%7D%2C%0A++++%7B%0A++++++%22sentenceArray%22%3A+%5B%0A++++++++%7B%0A++++++++++%22path%22%3A+%7B%0A++++++++++++%22type%22%3A+%22walk%22%2C%0A++++++++++++%22nodes%22%3A+%5B%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952614%2C%0A++++++++++++++++%22lng%22%3A+32.854491%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952083%2C%0A++++++++++++++++%22lng%22%3A+32.857761%0A++++++++++++++%7D%0A++++++++++++%5D%0A++++++++++%7D%0A++++++++%7D%2C%0A++++++++%7B%0A++++++++++%22path%22%3A+%7B%0A++++++++++++%22type%22%3A+%22bus%22%2C%0A++++++++++++%22nodes%22%3A+%5B%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952418%2C%0A++++++++++++++++%22lng%22%3A+32.85727%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.952797%2C%0A++++++++++++++++%22lng%22%3A+32.856825%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.953102%2C%0A++++++++++++++++%22lng%22%3A+32.856438%0A++++++++++++++%7D%0A++++++++++++%5D%0A++++++++++%7D%0A++++++++%7D%2C%0A++++++++%7B%0A++++++++++%22path%22%3A+%7B%0A++++++++++++%22type%22%3A+%22bus%22%2C%0A++++++++++++%22nodes%22%3A+%5B%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.964951%2C%0A++++++++++++++++%22lng%22%3A+32.841305%0A++++++++++++++%7D%2C%0A++++++++++++++%7B%0A++++++++++++++++%22lat%22%3A+39.964785%2C%0A++++++++++++++++%22lng%22%3A+32.841514%0A++++++++++++++%7D%0A++++++++++++%5D%0A++++++++++%7D%0A++++++++%7D%0A++++++%5D%0A++++%7D%0A++%5D%0A%7D'
  113     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
  114     6        FETCH_DIM_R                                      ~8      !1, 'data'
          7      > FE_RESET_R                                       $9      ~8, ->27
          8    > > FE_FETCH_R                                               $9, !2, ->27
  115     9    >   FETCH_DIM_R                                      ~10     !2, 'sentenceArray'
         10      > FE_RESET_R                                       $11     ~10, ->25
         11    > > FE_FETCH_R                                               $11, !3, ->25
  116    12    >   FETCH_DIM_R                                      ~12     !3, 'path'
         13        FETCH_DIM_R                                      ~13     ~12, 'type'
         14        IS_EQUAL                                         ~14     ~13, 'bus'
         15      > JMPZ_EX                                          ~14     ~14, ->19
         16    >   FETCH_DIM_IS                                     ~15     !3, 'path'
         17        ISSET_ISEMPTY_DIM_OBJ                         0  ~16     ~15, 'nodes'
         18        BOOL                                             ~14     ~16
         19    > > JMPZ                                                     ~14, ->24
  117    20    >   FETCH_DIM_R                                      ~18     !3, 'path'
         21        FETCH_DIM_R                                      ~19     ~18, 'nodes'
         22        ASSIGN_DIM                                               !4
         23        OP_DATA                                                  ~19
  115    24    > > JMP                                                      ->11
         25    >   FE_FREE                                                  $11
  114    26      > JMP                                                      ->8
         27    >   FE_FREE                                                  $9
  121    28        INIT_FCALL                                               'json_encode'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $20     
         31        ECHO                                                     $20
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.49 ms | 1006 KiB | 15 Q