3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array ('location' => 'X33', 'usernumber' => 1, 'order' => 'XX', 'part_number' => 'Hi' ), array ('location' => 'X33', 'usernumber' => 1, 'order' => 'XX', 'part_number' => '68730' ), array ('location' => 'W33', 'usernumber' => 2, 'order' => 'YY', 'part_number' => '68741' ), array ('location' => 'W33', 'usernumber' => 2, 'order' => 'YY', 'part_number' => 'Hello' ) ); $out = array(); $index = $arr[0]['usernumber']; foreach($arr as $val){ if($index != $val['usernumber']) $index = $val['usernumber']; $out[$index][] = $val; } echo '<pre>'; print_r($out);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/G3sl6
function name:  (null)
number of ops:  22
compiled vars:  !0 = $arr, !1 = $out, !2 = $index, !3 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, <array>
   26     2        FETCH_DIM_R                                      ~6      !0, 0
          3        FETCH_DIM_R                                      ~7      ~6, 'usernumber'
          4        ASSIGN                                                   !2, ~7
   27     5      > FE_RESET_R                                       $9      !0, ->16
          6    > > FE_FETCH_R                                               $9, !3, ->16
   28     7    >   FETCH_DIM_R                                      ~10     !3, 'usernumber'
          8        IS_NOT_EQUAL                                             !2, ~10
          9      > JMPZ                                                     ~11, ->12
   29    10    >   FETCH_DIM_R                                      ~12     !3, 'usernumber'
         11        ASSIGN                                                   !2, ~12
   30    12    >   FETCH_DIM_W                                      $14     !1, !2
         13        ASSIGN_DIM                                               $14
         14        OP_DATA                                                  !3
   27    15      > JMP                                                      ->6
         16    >   FE_FREE                                                  $9
   32    17        ECHO                                                     '%3Cpre%3E'
   33    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.08 ms | 1010 KiB | 14 Q