3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jsons=[ 'Single'=>'{"docID":451287,"list":{"id":77,"color":"pink"}}', 'Multiple'=>'{"docID":451287,"list":[{"id":85,"color":"blue"},{"id":47,"color":"red"},{"id":12,"color":"green"}]}' ]; foreach($jsons as $type=>$json){ $array=json_decode($json,true); if(isset($array['list']['color'])){ echo "Type = $type, Value = {$array['list']['color']}"; }else{ echo "Type = $type, Values = ",implode(', ',array_column($array['list'],'color')); } echo "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 36
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 36
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/sT46v
function name:  (null)
number of ops:  38
compiled vars:  !0 = $jsons, !1 = $json, !2 = $type, !3 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    7     1      > FE_RESET_R                                       $5      !0, ->36
          2    > > FE_FETCH_R                                       ~6      $5, !1, ->36
          3    >   ASSIGN                                                   !2, ~6
    8     4        INIT_FCALL                                               'json_decode'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !3, $8
    9     9        FETCH_DIM_IS                                     ~10     !3, 'list'
         10        ISSET_ISEMPTY_DIM_OBJ                         0          ~10, 'color'
         11      > JMPZ                                                     ~11, ->20
   10    12    >   ROPE_INIT                                     4  ~15     'Type+%3D+'
         13        ROPE_ADD                                      1  ~15     ~15, !2
         14        ROPE_ADD                                      2  ~15     ~15, '%2C+Value+%3D+'
         15        FETCH_DIM_R                                      ~12     !3, 'list'
         16        FETCH_DIM_R                                      ~13     ~12, 'color'
         17        ROPE_END                                      3  ~14     ~15, ~13
         18        ECHO                                                     ~14
    9    19      > JMP                                                      ->34
   12    20    >   ROPE_INIT                                     3  ~18     'Type+%3D+'
         21        ROPE_ADD                                      1  ~18     ~18, !2
         22        ROPE_END                                      2  ~17     ~18, '%2C+Values+%3D+'
         23        ECHO                                                     ~17
         24        INIT_FCALL                                               'implode'
         25        SEND_VAL                                                 '%2C+'
         26        INIT_FCALL                                               'array_column'
         27        FETCH_DIM_R                                      ~20     !3, 'list'
         28        SEND_VAL                                                 ~20
         29        SEND_VAL                                                 'color'
         30        DO_ICALL                                         $21     
         31        SEND_VAR                                                 $21
         32        DO_ICALL                                         $22     
         33        ECHO                                                     $22
   14    34    >   ECHO                                                     '%0A'
    7    35      > JMP                                                      ->2
         36    >   FE_FREE                                                  $5
   15    37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.88 ms | 1007 KiB | 16 Q