3v4l.org

run code in 500+ PHP versions simultaneously
<?php $input = "objectId | 19 location.street | Rue des clochets translations.fr.idTranslation | 4"; $output = []; $lines = explode("\n", $input); foreach ($lines as $line) { $cols = explode("|", $line); $key = trim($cols[0]); $value = trim($cols[1]); $indices = explode('.', $key); $first = array_shift($indices); if (!isset($output[$first])) $output[$first] = []; $target = &$output[$first]; foreach ($indices as $index) { if (!isset($target[$index])) { $target[$index] = []; $target = &$target[$index]; } } $target = $value; } var_dump($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 49
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 49
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 46
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 46
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 45
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 46
Branch analysis from position: 34
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
filename:       /in/sLvXp
function name:  (null)
number of ops:  54
compiled vars:  !0 = $input, !1 = $output, !2 = $lines, !3 = $line, !4 = $cols, !5 = $key, !6 = $value, !7 = $indices, !8 = $first, !9 = $target, !10 = $index
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'objectId++++++++++++++++++++++++%7C+++19%0Alocation.street+++++++++++++++++%7C+++Rue+des+clochets%0Atranslations.fr.idTranslation+++%7C+++4'
    7     1        ASSIGN                                                       !1, <array>
    9     2        INIT_FCALL                                                   'explode'
          3        SEND_VAL                                                     '%0A'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $13     
          6        ASSIGN                                                       !2, $13
   10     7      > FE_RESET_R                                           $15     !2, ->49
          8    > > FE_FETCH_R                                                   $15, !3, ->49
   11     9    >   INIT_FCALL                                                   'explode'
         10        SEND_VAL                                                     '%7C'
         11        SEND_VAR                                                     !3
         12        DO_ICALL                                             $16     
         13        ASSIGN                                                       !4, $16
   12    14        FETCH_DIM_R                                          ~18     !4, 0
         15        FRAMELESS_ICALL_1                trim                ~19     ~18
         16        ASSIGN                                                       !5, ~19
   13    17        FETCH_DIM_R                                          ~21     !4, 1
         18        FRAMELESS_ICALL_1                trim                ~22     ~21
         19        ASSIGN                                                       !6, ~22
   14    20        INIT_FCALL                                                   'explode'
         21        SEND_VAL                                                     '.'
         22        SEND_VAR                                                     !5
         23        DO_ICALL                                             $24     
         24        ASSIGN                                                       !7, $24
   15    25        INIT_FCALL                                                   'array_shift'
         26        SEND_REF                                                     !7
         27        DO_ICALL                                             $26     
         28        ASSIGN                                                       !8, $26
   16    29        ISSET_ISEMPTY_DIM_OBJ                             0  ~28     !1, !8
         30        BOOL_NOT                                             ~29     ~28
         31      > JMPZ                                                         ~29, ->34
   17    32    >   ASSIGN_DIM                                                   !1, !8
         33        OP_DATA                                                      <array>
   18    34    >   FETCH_DIM_W                                          $31     !1, !8
         35        ASSIGN_REF                                                   !9, $31
   19    36      > FE_RESET_R                                           $33     !7, ->46
         37    > > FE_FETCH_R                                                   $33, !10, ->46
   20    38    >   ISSET_ISEMPTY_DIM_OBJ                             0  ~34     !9, !10
         39        BOOL_NOT                                             ~35     ~34
         40      > JMPZ                                                         ~35, ->45
   21    41    >   ASSIGN_DIM                                                   !9, !10
         42        OP_DATA                                                      <array>
   22    43        FETCH_DIM_W                                          $37     !9, !10
         44        ASSIGN_REF                                                   !9, $37
   19    45    > > JMP                                                          ->37
         46    >   FE_FREE                                                      $33
   25    47        ASSIGN                                                       !9, !6
   10    48      > JMP                                                          ->8
         49    >   FE_FREE                                                      $15
   28    50        INIT_FCALL                                                   'var_dump'
         51        SEND_VAR                                                     !1
         52        DO_ICALL                                                     
         53      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.96 ms | 2643 KiB | 16 Q