3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array= [ ['name' => 'block.0.name', 'value' => 'vda'], ['name' => 'block.0.backingIndex', 'value' => 2], ['name' => 'block.0.rd.reqs', 'value' => 248907], ['name' => 'block.0.rd.bytes', 'value' => 9842014208], ['name' => 'block.0.rd.times', 'value' => 372870570891], ['name' => 'block.1.name', 'value' => 'hda'], ['name' => 'block.1.backingIndex', 'value' => 30], ['name' => 'block.1.rd.reqs', 'value' => 2871], ['name' => 'block.1.rd.bytes', 'value' => 9677156], ['name' => 'block.1.rd.times', 'value' => 620637479], ['name' => 'block.2.name', 'value' => 'cda'], ['name' => 'block.2.backingIndex', 'value' => 30], ['name' => 'block.2.rd.reqs', 'value' => 2871], ['name' => 'block.2.rd.bytes', 'value' => 9677156], ['name' => 'block.2.rd.times', 'value' => 620637479], ['name' => 'vcpu.0.state', 'value' => 1], ['name' => 'vcpu.0.time', 'value' => 963654400000000], ['name' => 'vcpu.0.wait', 'value' => 0], ['name' => 'vcpu.1.state', 'value' => 1], ['name' => 'vcpu.1.time', 'value' => 936409070000000], ['name' => 'vcpu.1.wait', 'value' => 0], ['name' => 'vcpu.2.state', 'value' => 1], ['name' => 'vcpu.2.time', 'value' => 943396180000000], ['name' => 'vcpu.2.wait', 'value' => 0], ['name' => 'vcpu.3.state', 'value' => 1], ['name' => 'vcpu.3.time', 'value' => 959496330000000], ['name' => 'vcpu.3.wait', 'value' => 0], ['name' => 'balloon.current', 'value' => 16777216], ['name' => 'balloon.maximum', 'value' => 34534530], ['name' => 'balloon.swap_in', 'value' => 0], ['name' => 'balloon.swap_out', 'value' => 0], ['name' => 'balloon.major_fault', 'value' => 262], ['name' => 'balloon.minor_fault', 'value' => 132293], ['name' => 'balloon.unused', 'value' => 16153712], ['name' => 'balloon.available', 'value' => 16396312], ]; $result = []; foreach ($array as ['name' => $name, 'value' => $value]) { $parts = explode('.', $name); $parentKey = $parts[0] . 's'; $childKey = implode(array_splice($parts, 0, ctype_digit($parts[1]) ? 2 : 1)); $grandchildKey = implode('.', $parts); if ($grandchildKey !== 'name') { $result[$parentKey][$childKey][$grandchildKey] = $value; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 41
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 41
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 40
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 40
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 40
Branch analysis from position: 36
Branch analysis from position: 40
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/qlaZL
function name:  (null)
number of ops:  46
compiled vars:  !0 = $array, !1 = $result, !2 = $name, !3 = $value, !4 = $parts, !5 = $parentKey, !6 = $childKey, !7 = $grandchildKey
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   41     1        ASSIGN                                                       !1, <array>
   42     2      > FE_RESET_R                                           $10     !0, ->41
          3    > > FE_FETCH_R                                                   $10, $11, ->41
          4    >   FETCH_LIST_R                                         $12     $11, 'name'
          5        ASSIGN                                                       !2, $12
          6        FETCH_LIST_R                                         $14     $11, 'value'
          7        ASSIGN                                                       !3, $14
          8        FREE                                                         $11
   43     9        INIT_FCALL                                                   'explode'
         10        SEND_VAL                                                     '.'
         11        SEND_VAR                                                     !2
         12        DO_ICALL                                             $16     
         13        ASSIGN                                                       !4, $16
   44    14        FETCH_DIM_R                                          ~18     !4, 0
         15        CONCAT                                               ~19     ~18, 's'
         16        ASSIGN                                                       !5, ~19
   45    17        INIT_FCALL                                                   'array_splice'
         18        SEND_REF                                                     !4
         19        SEND_VAL                                                     0
         20        INIT_FCALL                                                   'ctype_digit'
         21        FETCH_DIM_R                                          ~21     !4, 1
         22        SEND_VAL                                                     ~21
         23        DO_ICALL                                             $22     
         24      > JMPZ                                                         $22, ->27
         25    >   QM_ASSIGN                                            ~23     2
         26      > JMP                                                          ->28
         27    >   QM_ASSIGN                                            ~23     1
         28    >   SEND_VAL                                                     ~23
         29        DO_ICALL                                             $24     
         30        FRAMELESS_ICALL_1                implode             ~25     $24
         31        ASSIGN                                                       !6, ~25
   46    32        FRAMELESS_ICALL_2                implode             ~27     '.', !4
         33        ASSIGN                                                       !7, ~27
   47    34        IS_NOT_IDENTICAL                                             !7, 'name'
         35      > JMPZ                                                         ~29, ->40
   48    36    >   FETCH_DIM_W                                          $30     !1, !5
         37        FETCH_DIM_W                                          $31     $30, !6
         38        ASSIGN_DIM                                                   $31, !7
         39        OP_DATA                                                      !3
   42    40    > > JMP                                                          ->3
         41    >   FE_FREE                                                      $10
   51    42        INIT_FCALL                                                   'var_export'
         43        SEND_VAR                                                     !1
         44        DO_ICALL                                                     
         45      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.18 ms | 2276 KiB | 18 Q