3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jsonfile = '{ "ph": { "name": "Philippines", "color": "green" }, "ch": { "name": "China", "color": "red" }, "us": { "name": "USA", "color": "blue" } }'; $data = json_decode($jsonfile, true); foreach ($data as $key => $value) { if ($key == 'ph') { echo $value['name'] . ': ' . $value['color'] . PHP_EOL; } } if (array_key_exists('ph', $data)) { echo $data['ph']['name'] . ': ' . $data['ph']['color']. PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 18
filename:       /in/Qj5AQ
function name:  (null)
number of ops:  30
compiled vars:  !0 = $jsonfile, !1 = $data, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22ph%22%3A+%7B%0A++++++++%22name%22%3A+%22Philippines%22%2C%0A++++++++%22color%22%3A+%22green%22%0A++++%7D%2C%0A%0A++++%22ch%22%3A+%7B%0A++++++++%22name%22%3A+%22China%22%2C%0A++++++++%22color%22%3A+%22red%22%0A++++%7D%2C%0A%0A++++%22us%22%3A+%7B%0A++++++++%22name%22%3A+%22USA%22%2C%0A++++++++%22color%22%3A+%22blue%22%0A++++%7D%0A%0A%7D'
   20     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   21     6      > FE_RESET_R                                       $7      !1, ->18
          7    > > FE_FETCH_R                                       ~8      $7, !2, ->18
          8    >   ASSIGN                                                   !3, ~8
   22     9        IS_EQUAL                                                 !3, 'ph'
         10      > JMPZ                                                     ~10, ->17
   23    11    >   FETCH_DIM_R                                      ~11     !2, 'name'
         12        CONCAT                                           ~12     ~11, '%3A+'
         13        FETCH_DIM_R                                      ~13     !2, 'color'
         14        CONCAT                                           ~14     ~12, ~13
         15        CONCAT                                           ~15     ~14, '%0A'
         16        ECHO                                                     ~15
   21    17    > > JMP                                                      ->7
         18    >   FE_FREE                                                  $7
   27    19        ARRAY_KEY_EXISTS                                         'ph', !1
         20      > JMPZ                                                     ~16, ->29
   28    21    >   FETCH_DIM_R                                      ~17     !1, 'ph'
         22        FETCH_DIM_R                                      ~18     ~17, 'name'
         23        CONCAT                                           ~19     ~18, '%3A+'
         24        FETCH_DIM_R                                      ~20     !1, 'ph'
         25        FETCH_DIM_R                                      ~21     ~20, 'color'
         26        CONCAT                                           ~22     ~19, ~21
         27        CONCAT                                           ~23     ~22, '%0A'
         28        ECHO                                                     ~23
   29    29    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138 ms | 1001 KiB | 14 Q