3v4l.org

run code in 300+ PHP versions simultaneously
<?php function l($name) { $a = ["a" => "aaa", "b" => ["a"=>"123456"], "c" => ["d"=>["e" =>"1%1"]]]; $keys = explode(".", $name); $key = array_shift($keys); $result = isset($a[$key]) ? $a[$key] : null; foreach($keys as $k) { if(!$result) return $name; $result = isset($result[$k]) ? $result[$k] : null; } $args = func_get_args(); foreach($args as $k => $v) $result = str_replace("%{$k}", $v, $result); return $result; } var_dump(l("a")); var_dump(l("b.a")); var_dump(l("b.c")); var_dump(l("c.d.e", 45));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2nt3j
function name:  (null)
number of ops:  26
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'l'
          2        SEND_VAL                                                 'a'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   27     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'l'
          8        SEND_VAL                                                 'b.a'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   28    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'l'
         14        SEND_VAL                                                 'b.c'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   29    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'l'
         20        SEND_VAL                                                 'c.d.e'
         21        SEND_VAL                                                 45
         22        DO_FCALL                                      0  $6      
         23        SEND_VAR                                                 $6
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Function l:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 32
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 32
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 36, Position 2 = 47
Branch analysis from position: 36
2 jumps found. (Code = 78) Position 1 = 37, Position 2 = 47
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 32
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 32
Branch analysis from position: 19
Branch analysis from position: 32
filename:       /in/2nt3j
function name:  l
number of ops:  50
compiled vars:  !0 = $name, !1 = $a, !2 = $keys, !3 = $key, !4 = $result, !5 = $k, !6 = $args, !7 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, <array>
    8     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '.'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !2, $9
   10     7        INIT_FCALL                                               'array_shift'
          8        SEND_REF                                                 !2
          9        DO_ICALL                                         $11     
         10        ASSIGN                                                   !3, $11
   11    11        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !3
         12      > JMPZ                                                     ~13, ->16
         13    >   FETCH_DIM_R                                      ~14     !1, !3
         14        QM_ASSIGN                                        ~15     ~14
         15      > JMP                                                      ->17
         16    >   QM_ASSIGN                                        ~15     null
         17    >   ASSIGN                                                   !4, ~15
   13    18      > FE_RESET_R                                       $17     !2, ->32
         19    > > FE_FETCH_R                                               $17, !5, ->32
   15    20    >   BOOL_NOT                                         ~18     !4
         21      > JMPZ                                                     ~18, ->24
   16    22    >   FE_FREE                                                  $17
         23      > RETURN                                                   !0
   17    24    >   ISSET_ISEMPTY_DIM_OBJ                         0          !4, !5
         25      > JMPZ                                                     ~19, ->29
         26    >   FETCH_DIM_R                                      ~20     !4, !5
         27        QM_ASSIGN                                        ~21     ~20
         28      > JMP                                                      ->30
         29    >   QM_ASSIGN                                        ~21     null
         30    >   ASSIGN                                                   !4, ~21
   13    31      > JMP                                                      ->19
         32    >   FE_FREE                                                  $17
   20    33        FUNC_GET_ARGS                                    ~23     
         34        ASSIGN                                                   !6, ~23
   21    35      > FE_RESET_R                                       $25     !6, ->47
         36    > > FE_FETCH_R                                       ~26     $25, !7, ->47
         37    >   ASSIGN                                                   !5, ~26
   22    38        INIT_FCALL                                               'str_replace'
         39        NOP                                                      
         40        FAST_CONCAT                                      ~28     '%25', !5
         41        SEND_VAL                                                 ~28
         42        SEND_VAR                                                 !7
         43        SEND_VAR                                                 !4
         44        DO_ICALL                                         $29     
         45        ASSIGN                                                   !4, $29
   21    46      > JMP                                                      ->36
         47    >   FE_FREE                                                  $25
   23    48      > RETURN                                                   !4
   24    49*     > RETURN                                                   null

End of function l

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.64 ms | 1407 KiB | 25 Q