3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( '0' => Array ( 'product_id' => 6, 'brand_id' => 2 ) , '1' => Array ( 'product_id' => 1, 'brand_id' => 1 ) , '2' => Array ( 'product_id' => 5, 'brand_id' => 1 ) ); $key = 'brand_id'; $return = array(); foreach($array as $v) { $return[$v[$key]][] = $v; } print_r(array_values($return)); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 10
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/bHuWV
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array, !1 = $key, !2 = $return, !3 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, 'brand_id'
   26     2        ASSIGN                                                   !2, <array>
   27     3      > FE_RESET_R                                       $7      !0, ->10
          4    > > FE_FETCH_R                                               $7, !3, ->10
   28     5    >   FETCH_DIM_R                                      ~8      !3, !1
          6        FETCH_DIM_W                                      $9      !2, ~8
          7        ASSIGN_DIM                                               $9
          8        OP_DATA                                                  !3
   27     9      > JMP                                                      ->4
         10    >   FE_FREE                                                  $7
   30    11        INIT_FCALL                                               'print_r'
         12        INIT_FCALL                                               'array_values'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $11     
         15        SEND_VAR                                                 $11
         16        DO_ICALL                                                 
   31    17      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.11 ms | 953 KiB | 15 Q