3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testArray = array( 'router' => array( 'format' => 'xml', ), ); function array_get($array, $key, $default = null) { if (is_null($key)) return $array; if (isset($array[$key])) return $array[$key]; foreach (explode('.', $key) as $segment) { if ( ! is_array($array) or ! array_key_exists($segment, $array)) { return value($default); } $array = $array[$segment]; } return $array; } function value($value) { return $value instanceof Closure ? $value() : $value; } var_dump(array_get($testArray, 'router.format'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NCPkl
function name:  (null)
number of ops:  9
compiled vars:  !0 = $testArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_get'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'router.format'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function array_get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 31
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 31
Branch analysis from position: 16
2 jumps found. (Code = 47) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 22
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/NCPkl
function name:  array_get
number of ops:  34
compiled vars:  !0 = $array, !1 = $key, !2 = $default, !3 = $segment
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   11     3        TYPE_CHECK                                    2          !1
          4      > JMPZ                                                     ~4, ->6
          5    > > RETURN                                                   !0
   12     6    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !1
          7      > JMPZ                                                     ~5, ->10
          8    >   FETCH_DIM_R                                      ~6      !0, !1
          9      > RETURN                                                   ~6
   13    10    >   INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '.'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $7      
         14      > FE_RESET_R                                       $8      $7, ->31
         15    > > FE_FETCH_R                                               $8, !3, ->31
   15    16    >   TYPE_CHECK                                  128  ~9      !0
         17        BOOL_NOT                                         ~10     ~9
         18      > JMPNZ_EX                                         ~10     ~10, ->22
         19    >   ARRAY_KEY_EXISTS                                 ~11     !3, !0
         20        BOOL_NOT                                         ~12     ~11
         21        BOOL                                             ~10     ~12
         22    > > JMPZ                                                     ~10, ->28
   17    23    >   INIT_FCALL_BY_NAME                                       'value'
         24        SEND_VAR_EX                                              !2
         25        DO_FCALL                                      0  $13     
         26        FE_FREE                                                  $8
         27      > RETURN                                                   $13
   20    28    >   FETCH_DIM_R                                      ~14     !0, !3
         29        ASSIGN                                                   !0, ~14
   13    30      > JMP                                                      ->15
         31    >   FE_FREE                                                  $8
   23    32      > RETURN                                                   !0
   24    33*     > RETURN                                                   null

End of function array_get

Function value:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NCPkl
function name:  value
number of ops:  10
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   28     1        INSTANCEOF                                               !0, 'Closure'
          2      > JMPZ                                                     ~1, ->7
          3    >   INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0  $2      
          5        QM_ASSIGN                                        ~3      $2
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~3      !0
          8    > > RETURN                                                   ~3
   29     9*     > RETURN                                                   null

End of function value

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.88 ms | 1403 KiB | 18 Q