3v4l.org

run code in 300+ PHP versions simultaneously
<?php function dirToArray($dir) { $result = array(); $cdir = scandir($dir); foreach ($cdir as $key => $value) { if (!in_array($value,array(".",".."))) { if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) { $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value); } else { $result[] = $value; } } } return $result; } print_r(dirToArray('/'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/V9R4Q
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'dirtoarray'
          2        SEND_VAL                                                 '%2F'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Function dirtoarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 29
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 28
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/V9R4Q
function name:  dirToArray
number of ops:  32
compiled vars:  !0 = $dir, !1 = $result, !2 = $cdir, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'scandir'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !2, $6
    7     6      > FE_RESET_R                                       $8      !2, ->29
          7    > > FE_FETCH_R                                       ~9      $8, !3, ->29
          8    >   ASSIGN                                                   !4, ~9
    9     9        IN_ARRAY                                         ~11     !3, <array>
         10        BOOL_NOT                                         ~12     ~11
         11      > JMPZ                                                     ~12, ->28
   11    12    >   INIT_FCALL                                               'is_dir'
         13        CONCAT                                           ~13     !0, '%2F'
         14        CONCAT                                           ~14     ~13, !3
         15        SEND_VAL                                                 ~14
         16        DO_ICALL                                         $15     
         17      > JMPZ                                                     $15, ->26
   13    18    >   INIT_FCALL_BY_NAME                                       'dirToArray'
         19        CONCAT                                           ~17     !0, '%2F'
         20        CONCAT                                           ~18     ~17, !3
         21        SEND_VAL_EX                                              ~18
         22        DO_FCALL                                      0  $19     
         23        ASSIGN_DIM                                               !1, !3
         24        OP_DATA                                                  $19
         25      > JMP                                                      ->28
   17    26    >   ASSIGN_DIM                                               !1
         27        OP_DATA                                                  !3
    7    28    > > JMP                                                      ->7
         29    >   FE_FREE                                                  $8
   22    30      > RETURN                                                   !1
   23    31*     > RETURN                                                   null

End of function dirtoarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.85 ms | 1403 KiB | 20 Q