3v4l.org

run code in 500+ PHP versions simultaneously
<?php $paths = [ "fileZ.php", "folder1/content/file1.php", "folder1/content/file2.php", "folder1/edit/file1.php", "folder1/edit/file2.php", "folder1/pagination/file1.php", "folder1/pagination/file2.php", "folder1/toolbar/file1.php", "folder1/toolbar/file2.php", "folder2/cms/html/file1.php", "folder2/cms/html/file2.php" ]; $result = []; foreach ($paths as $path) { $temp = &$result; $entries = explode("/", $path); $file = array_pop($entries); foreach($entries as $folder) { $temp = &$temp[$folder]; } $temp[] = $file; unset($temp); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/JC8ce
function name:  (null)
number of ops:  29
compiled vars:  !0 = $paths, !1 = $result, !2 = $path, !3 = $temp, !4 = $entries, !5 = $file, !6 = $folder
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   16     1        ASSIGN                                                       !1, <array>
   17     2      > FE_RESET_R                                           $9      !0, ->24
          3    > > FE_FETCH_R                                                   $9, !2, ->24
   18     4    >   ASSIGN_REF                                                   !3, !1
   19     5        INIT_FCALL                                                   'explode'
          6        SEND_VAL                                                     '%2F'
          7        SEND_VAR                                                     !2
          8        DO_ICALL                                             $11     
          9        ASSIGN                                                       !4, $11
   20    10        INIT_FCALL                                                   'array_pop'
         11        SEND_REF                                                     !4
         12        DO_ICALL                                             $13     
         13        ASSIGN                                                       !5, $13
   21    14      > FE_RESET_R                                           $15     !4, ->19
         15    > > FE_FETCH_R                                                   $15, !6, ->19
   22    16    >   FETCH_DIM_W                                          $16     !3, !6
         17        ASSIGN_REF                                                   !3, $16
   21    18      > JMP                                                          ->15
         19    >   FE_FREE                                                      $15
   24    20        ASSIGN_DIM                                                   !3
         21        OP_DATA                                                      !5
   25    22        UNSET_CV                                                     !3
   17    23      > JMP                                                          ->3
         24    >   FE_FREE                                                      $9
   27    25        INIT_FCALL                                                   'var_export'
         26        SEND_VAR                                                     !1
         27        DO_ICALL                                                     
         28      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.74 ms | 2737 KiB | 15 Q