3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = ['dir2', 'dir2_1', 'dir2_1_1']; function convert_array(array $input, array $output = []) { if (empty($input)) { return $output; } $value = array_pop($input); return convert_array($input, [$value => $output]); } var_dump(convert_array($input));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m5Cup
function name:  (null)
number of ops:  8
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'convert_array'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function convert_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/m5Cup
function name:  convert_array
number of ops:  16
compiled vars:  !0 = $input, !1 = $output, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
    6     2        ISSET_ISEMPTY_CV                                         !0
          3      > JMPZ                                                     ~3, ->5
    7     4    > > RETURN                                                   !1
   10     5    >   INIT_FCALL                                               'array_pop'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                         $4      
          8        ASSIGN                                                   !2, $4
   12     9        INIT_FCALL_BY_NAME                                       'convert_array'
         10        SEND_VAR_EX                                              !0
         11        INIT_ARRAY                                       ~6      !1, !2
         12        SEND_VAL_EX                                              ~6
         13        DO_FCALL                                      0  $7      
         14      > RETURN                                                   $7
   13    15*     > RETURN                                                   null

End of function convert_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.57 ms | 1398 KiB | 18 Q