3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hydratePath(array $result, ?string $path): array { if (sscanf($path ?? '', '%[^/]/%s', $first, $rest) < 2) { $result[] = $first ?? $path; } else { $result[$first] ??= []; $result[$first] = (__FUNCTION__)($result[$first], $rest); } return $result; } $array = [ 'invoice/products/data/item1', '', null, 'invoice/products/data/item2', 'invoice/products/filename', 'invoice/products/data/item2', 'foo/bar/baz', '', 'aaa/bbb' ]; var_export(array_reduce($array, "hydratePath", []));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CUbUQ
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   26     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'hydratePath'
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function hydratepath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CUbUQ
function name:  hydratePath
number of ops:  35
compiled vars:  !0 = $result, !1 = $path, !2 = $first, !3 = $rest
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'sscanf'
          3        COALESCE                                         ~4      !1
          4        QM_ASSIGN                                        ~4      ''
          5        SEND_VAL                                                 ~4
          6        SEND_VAL                                                 '%25%5B%5E%2F%5D%2F%25s'
          7        SEND_REF                                                 !2
          8        SEND_REF                                                 !3
          9        DO_ICALL                                         $5      
         10        IS_SMALLER                                               $5, 2
         11      > JMPZ                                                     ~6, ->17
    6    12    >   COALESCE                                         ~8      !2
         13        QM_ASSIGN                                        ~8      !1
         14        ASSIGN_DIM                                               !0
         15        OP_DATA                                                  ~8
    5    16      > JMP                                                      ->31
    8    17    >   FETCH_DIM_IS                                     ~9      !0, !2
         18        COALESCE                                         ~10     ~9
         19        ASSIGN_DIM                                       ~11     !0, !2
         20        OP_DATA                                                  <array>
         21        QM_ASSIGN                                        ~10     ~11
         22        FREE                                                     ~10
    9    23        INIT_FCALL_BY_NAME                                       'hydratePath'
         24        CHECK_FUNC_ARG                                           
         25        FETCH_DIM_FUNC_ARG                               $13     !0, !2
         26        SEND_FUNC_ARG                                            $13
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0  $14     
         29        ASSIGN_DIM                                               !0, !2
         30        OP_DATA                                                  $14
   11    31    >   VERIFY_RETURN_TYPE                                       !0
         32      > RETURN                                                   !0
   12    33*       VERIFY_RETURN_TYPE                                       
         34*     > RETURN                                                   null

End of function hydratepath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.19 ms | 1012 KiB | 16 Q