3v4l.org

run code in 300+ 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 = 53
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 53
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 50
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 50
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 49
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 49
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 50
Branch analysis from position: 38
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
filename:       /in/sLvXp
function name:  (null)
number of ops:  58
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, ->53
          8    > > FE_FETCH_R                                               $15, !3, ->53
   11     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '%7C'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $16     
         13        ASSIGN                                                   !4, $16
   12    14        INIT_FCALL                                               'trim'
         15        FETCH_DIM_R                                      ~18     !4, 0
         16        SEND_VAL                                                 ~18
         17        DO_ICALL                                         $19     
         18        ASSIGN                                                   !5, $19
   13    19        INIT_FCALL                                               'trim'
         20        FETCH_DIM_R                                      ~21     !4, 1
         21        SEND_VAL                                                 ~21
         22        DO_ICALL                                         $22     
         23        ASSIGN                                                   !6, $22
   14    24        INIT_FCALL                                               'explode'
         25        SEND_VAL                                                 '.'
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                         $24     
         28        ASSIGN                                                   !7, $24
   15    29        INIT_FCALL                                               'array_shift'
         30        SEND_REF                                                 !7
         31        DO_ICALL                                         $26     
         32        ASSIGN                                                   !8, $26
   16    33        ISSET_ISEMPTY_DIM_OBJ                         0  ~28     !1, !8
         34        BOOL_NOT                                         ~29     ~28
         35      > JMPZ                                                     ~29, ->38
   17    36    >   ASSIGN_DIM                                               !1, !8
         37        OP_DATA                                                  <array>
   18    38    >   FETCH_DIM_W                                      $31     !1, !8
         39        ASSIGN_REF                                               !9, $31
   19    40      > FE_RESET_R                                       $33     !7, ->50
         41    > > FE_FETCH_R                                               $33, !10, ->50
   20    42    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~34     !9, !10
         43        BOOL_NOT                                         ~35     ~34
         44      > JMPZ                                                     ~35, ->49
   21    45    >   ASSIGN_DIM                                               !9, !10
         46        OP_DATA                                                  <array>
   22    47        FETCH_DIM_W                                      $37     !9, !10
         48        ASSIGN_REF                                               !9, $37
   19    49    > > JMP                                                      ->41
         50    >   FE_FREE                                                  $33
   25    51        ASSIGN                                                   !9, !6
   10    52      > JMP                                                      ->8
         53    >   FE_FREE                                                  $15
   28    54        INIT_FCALL                                               'var_dump'
         55        SEND_VAR                                                 !1
         56        DO_ICALL                                                 
         57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.16 ms | 1010 KiB | 17 Q