3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getValue($array, $keySpec){ foreach (explode('.', $keySpec) as $key){ if (!isset($array[$key])){ return null; } $array = $array[$key]; } return $array; } $array = [ 'userList' => [ '1234' => [ 'name' => 'Kicken' ] ] ]; var_dump(getValue($array, 'userList.1234.name'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AdcKW
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   23     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'getvalue'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'userList.1234.name'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function getvalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/AdcKW
function name:  getValue
number of ops:  19
compiled vars:  !0 = $array, !1 = $keySpec, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '.'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6      > FE_RESET_R                                       $4      $3, ->16
          7    > > FE_FETCH_R                                               $4, !2, ->16
    5     8    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~5      !0, !2
          9        BOOL_NOT                                         ~6      ~5
         10      > JMPZ                                                     ~6, ->13
    6    11    >   FE_FREE                                                  $4
         12      > RETURN                                                   null
    9    13    >   FETCH_DIM_R                                      ~7      !0, !2
         14        ASSIGN                                                   !0, ~7
    4    15      > JMP                                                      ->7
         16    >   FE_FREE                                                  $4
   12    17      > RETURN                                                   !0
   13    18*     > RETURN                                                   null

End of function getvalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.63 ms | 1403 KiB | 18 Q