3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ '71-ctns' => 1, '71-units' => 1, '308-units' => 1, '305-ctns' => 1, '306-units' => 2, ]; $result = []; foreach ($array as $k => $v) { [$id, $label] = explode('-', $k); $result[$id][$label] = $v; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/WcVlI
function name:  (null)
number of ops:  23
compiled vars:  !0 = $array, !1 = $result, !2 = $v, !3 = $k, !4 = $id, !5 = $label
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   11     1        ASSIGN                                                       !1, <array>
   12     2      > FE_RESET_R                                           $8      !0, ->18
          3    > > FE_FETCH_R                                           ~9      $8, !2, ->18
          4    >   ASSIGN                                                       !3, ~9
   13     5        INIT_FCALL                                                   'explode'
          6        SEND_VAL                                                     '-'
          7        SEND_VAR                                                     !3
          8        DO_ICALL                                             $11     
          9        FETCH_LIST_R                                         $12     $11, 0
         10        ASSIGN                                                       !4, $12
         11        FETCH_LIST_R                                         $14     $11, 1
         12        ASSIGN                                                       !5, $14
         13        FREE                                                         $11
   14    14        FETCH_DIM_W                                          $16     !1, !4
         15        ASSIGN_DIM                                                   $16, !5
         16        OP_DATA                                                      !2
   12    17      > JMP                                                          ->3
         18    >   FE_FREE                                                      $8
   16    19        INIT_FCALL                                                   'var_export'
         20        SEND_VAR                                                     !1
         21        DO_ICALL                                                     
         22      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.44 ms | 1656 KiB | 15 Q