3v4l.org

run code in 300+ PHP versions simultaneously
<?php const URLS = [ "http://site.com/", "http://site.com/save", "http://site.com/save/results", "http://site.com/save/results/path", "http://site.com/path/save/results", "http://site.com/save/path", "http://site.com/path/results", "http://site.com/Crawler4", "http://site.com/Crawler", ]; $seen = []; $siteStructure = []; foreach (URLS as $url) { ['scheme' => $scheme, 'host' => $host, 'path' => $path] = parse_url($url); $realm = $scheme . '://' . $host; $siteStructure[$realm] ??= []; $current = &$siteStructure[$realm]; $pathEls = preg_split('/[^a-zA-Z0-9]+/', $path, 0, PREG_SPLIT_NO_EMPTY); foreach ($pathEls as $el) { $current[$el] ??= []; $current = &$current[$el]; } unset($current); } var_dump($siteStructure);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 48
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 48
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 35, Position 2 = 45
Branch analysis from position: 35
2 jumps found. (Code = 78) Position 1 = 36, Position 2 = 45
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 45
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
filename:       /in/f7Lj8
function name:  (null)
number of ops:  53
compiled vars:  !0 = $seen, !1 = $siteStructure, !2 = $url, !3 = $scheme, !4 = $host, !5 = $path, !6 = $realm, !7 = $current, !8 = $pathEls, !9 = $el
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'URLS', <array>
   15     1        ASSIGN                                                   !0, <array>
   16     2        ASSIGN                                                   !1, <array>
   18     3        FETCH_CONSTANT                                   ~12     'URLS'
          4      > FE_RESET_R                                       $13     ~12, ->48
          5    > > FE_FETCH_R                                               $13, !2, ->48
   20     6    >   INIT_FCALL                                               'parse_url'
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $14     
          9        FETCH_LIST_R                                     $15     $14, 'scheme'
         10        ASSIGN                                                   !3, $15
         11        FETCH_LIST_R                                     $17     $14, 'host'
         12        ASSIGN                                                   !4, $17
         13        FETCH_LIST_R                                     $19     $14, 'path'
         14        ASSIGN                                                   !5, $19
         15        FREE                                                     $14
   22    16        CONCAT                                           ~21     !3, '%3A%2F%2F'
         17        CONCAT                                           ~22     ~21, !4
         18        ASSIGN                                                   !6, ~22
   23    19        FETCH_DIM_IS                                     ~24     !1, !6
         20        COALESCE                                         ~25     ~24
         21        ASSIGN_DIM                                       ~26     !1, !6
         22        OP_DATA                                                  <array>
         23        QM_ASSIGN                                        ~25     ~26
         24        FREE                                                     ~25
   24    25        FETCH_DIM_W                                      $27     !1, !6
         26        ASSIGN_REF                                               !7, $27
   26    27        INIT_FCALL                                               'preg_split'
         28        SEND_VAL                                                 '%2F%5B%5Ea-zA-Z0-9%5D%2B%2F'
         29        SEND_VAR                                                 !5
         30        SEND_VAL                                                 0
         31        SEND_VAL                                                 1
         32        DO_ICALL                                         $29     
         33        ASSIGN                                                   !8, $29
   28    34      > FE_RESET_R                                       $31     !8, ->45
         35    > > FE_FETCH_R                                               $31, !9, ->45
   30    36    >   FETCH_DIM_IS                                     ~32     !7, !9
         37        COALESCE                                         ~33     ~32
         38        ASSIGN_DIM                                       ~34     !7, !9
         39        OP_DATA                                                  <array>
         40        QM_ASSIGN                                        ~33     ~34
         41        FREE                                                     ~33
   31    42        FETCH_DIM_W                                      $35     !7, !9
         43        ASSIGN_REF                                               !7, $35
   28    44      > JMP                                                      ->35
         45    >   FE_FREE                                                  $31
   34    46        UNSET_CV                                                 !7
   18    47      > JMP                                                      ->5
         48    >   FE_FREE                                                  $13
   37    49        INIT_FCALL                                               'var_dump'
         50        SEND_VAR                                                 !1
         51        DO_ICALL                                                 
         52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.52 ms | 1404 KiB | 19 Q