3v4l.org

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

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

End of function l

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.58 ms | 1403 KiB | 25 Q