3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = '123.animal=cat 123.name=fred 123.food=fish 345.animal=dog petshop=zoonoria'; $ini = parse_ini_string($data); $result = []; foreach ($ini as $key => $value) { echo $key, ' => ', $value, PHP_EOL; $splitKey = explode('.', $key); $iniPtr = &$result; foreach($splitKey as $subKey) { if (!isset($iniPtr[$subKey])) { $iniPtr[$subKey] = null; } $iniPtr = &$iniPtr[$subKey]; } $iniPtr = $value; unset($iniPtr); } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 33
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 33
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 29
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 26
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 29
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/ZXPn2
function name:  (null)
number of ops:  38
compiled vars:  !0 = $data, !1 = $ini, !2 = $result, !3 = $value, !4 = $key, !5 = $splitKey, !6 = $iniPtr, !7 = $subKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '123.animal%3Dcat%0A++++123.name%3Dfred%0A++++123.food%3Dfish%0A++++345.animal%3Ddog%0A++++petshop%3Dzoonoria'
   10     1        INIT_FCALL                                               'parse_ini_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $9      
          4        ASSIGN                                                   !1, $9
   11     5        ASSIGN                                                   !2, <array>
   12     6      > FE_RESET_R                                       $12     !1, ->33
          7    > > FE_FETCH_R                                       ~13     $12, !3, ->33
          8    >   ASSIGN                                                   !4, ~13
   13     9        ECHO                                                     !4
         10        ECHO                                                     '+%3D%3E+'
         11        ECHO                                                     !3
         12        ECHO                                                     '%0A'
   14    13        INIT_FCALL                                               'explode'
         14        SEND_VAL                                                 '.'
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $15     
         17        ASSIGN                                                   !5, $15
   15    18        ASSIGN_REF                                               !6, !2
   16    19      > FE_RESET_R                                       $18     !5, ->29
         20    > > FE_FETCH_R                                               $18, !7, ->29
   17    21    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !6, !7
         22        BOOL_NOT                                         ~20     ~19
         23      > JMPZ                                                     ~20, ->26
         24    >   ASSIGN_DIM                                               !6, !7
         25        OP_DATA                                                  null
   18    26    >   FETCH_DIM_W                                      $22     !6, !7
         27        ASSIGN_REF                                               !6, $22
   16    28      > JMP                                                      ->20
         29    >   FE_FREE                                                  $18
   20    30        ASSIGN                                                   !6, !3
   21    31        UNSET_CV                                                 !6
   12    32      > JMP                                                      ->7
         33    >   FE_FREE                                                  $12
   24    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
283.8 ms | 1012 KiB | 16 Q