3v4l.org

run code in 300+ PHP versions simultaneously
<?php $productCodes = [ [ 'parent' => [ 'name' => 'finish', ], // ... ], [ 'parent' => [ 'name' => 'fixture', ], // ... ], [ 'parent' => [ 'name' => 'finish', ], // ... ], [ 'parent' => [ 'name' => 'finish', ], // ... ], [ 'parent' => [ 'name' => 'fixture', ], // ... ], ]; $result = []; foreach ($productCodes as $option) { $parentName = $option['parent']['name']; $result[$parentName]['title'] = $parentName; $result[$parentName]['items'][] = $option; } var_dump(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/u9XBk
function name:  (null)
number of ops:  23
compiled vars:  !0 = $productCodes, !1 = $result, !2 = $option, !3 = $parentName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   36     1        ASSIGN                                                   !1, <array>
   38     2      > FE_RESET_R                                       $6      !0, ->15
          3    > > FE_FETCH_R                                               $6, !2, ->15
   39     4    >   FETCH_DIM_R                                      ~7      !2, 'parent'
          5        FETCH_DIM_R                                      ~8      ~7, 'name'
          6        ASSIGN                                                   !3, ~8
   40     7        FETCH_DIM_W                                      $10     !1, !3
          8        ASSIGN_DIM                                               $10, 'title'
          9        OP_DATA                                                  !3
   41    10        FETCH_DIM_W                                      $12     !1, !3
         11        FETCH_DIM_W                                      $13     $12, 'items'
         12        ASSIGN_DIM                                               $13
         13        OP_DATA                                                  !2
   38    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $6
   44    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'array_values'
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $15     
         20        SEND_VAR                                                 $15
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
184.14 ms | 1001 KiB | 15 Q