3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['spubid' => 'A00502','sfirst'=>'J.','smi'=>'A.','slast'=>'Doe'], ['spubid' => 'A00502','sfirst'=>'J.','smi'=>'F.','slast'=>'Kennedy'], ['spubid' => 'A00502','sfirst'=>'B.','smi'=>'F.','slast'=>'James'], ['spubid' => 'BXXXXX','sfirst'=>'B.','smi'=>'F.','slast'=>'James'], ['spubid' => 'A00502','sfirst'=>'S.','smi'=>'M.','slast'=>'Williamson'], ]; $result = []; foreach ($array as $row) { $id = $row['spubid']; if (!isset($ref[$id])) { $ref[$id] = $row; $counter[$id] = 0; $result[] = &$ref[$id]; } else { unset($row['spubid']); ++$counter[$id]; foreach ($row as $k => $v) { $ref[$id][$k . $counter[$id]] = $v; } } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 32
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 32
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 30
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 30
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 30
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/8R8HL
function name:  (null)
number of ops:  37
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $id, !4 = $ref, !5 = $counter, !6 = $v, !7 = $k
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                                       $10     !0, ->32
          3    > > FE_FETCH_R                                               $10, !2, ->32
   13     4    >   FETCH_DIM_R                                      ~11     !2, 'spubid'
          5        ASSIGN                                                   !3, ~11
   14     6        ISSET_ISEMPTY_DIM_OBJ                         0  ~13     !4, !3
          7        BOOL_NOT                                         ~14     ~13
          8      > JMPZ                                                     ~14, ->18
   15     9    >   ASSIGN_DIM                                               !4, !3
         10        OP_DATA                                                  !2
   16    11        ASSIGN_DIM                                               !5, !3
         12        OP_DATA                                                  0
   17    13        FETCH_DIM_W                                      $18     !4, !3
         14        MAKE_REF                                         $19     $18
         15        FETCH_DIM_W                                      $17     !1
         16        ASSIGN_REF                                               $17, $19
   14    17      > JMP                                                      ->31
   19    18    >   UNSET_DIM                                                !2, 'spubid'
   20    19        FETCH_DIM_RW                                     $21     !5, !3
         20        PRE_INC                                                  $21
   21    21      > FE_RESET_R                                       $23     !2, ->30
         22    > > FE_FETCH_R                                       ~24     $23, !6, ->30
         23    >   ASSIGN                                                   !7, ~24
   22    24        FETCH_DIM_R                                      ~27     !5, !3
         25        CONCAT                                           ~28     !7, ~27
         26        FETCH_DIM_W                                      $26     !4, !3
         27        ASSIGN_DIM                                               $26, ~28
         28        OP_DATA                                                  !6
   21    29      > JMP                                                      ->22
         30    >   FE_FREE                                                  $23
   12    31    > > JMP                                                      ->3
         32    >   FE_FREE                                                  $10
   26    33        INIT_FCALL                                               'var_export'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.08 ms | 1018 KiB | 14 Q