3v4l.org

run code in 300+ PHP versions simultaneously
<?php $results = [ [ 'id' => '1000', 'name' => 'Nurten', 'pId' => '26', 'anzahl' => '1', 'pName' => 'Fitness-Teller', 'preis' => '12.90', ], [ 'id' => '1001', 'name' => 'Kutscha', 'pId' => '94', 'anzahl' => '1', 'pName' => 'Pizza Parma', 'preis' => '12.90', ], [ 'id' => '1001', 'name' => 'Kutscha', 'pId' => '75', 'anzahl' => '1', 'pName' => 'Pizza Margherita', 'preis' => '6.50', ], ]; $out = []; foreach ($results as $result) { if (!isset($out[$result['id']])) { $out[$result['id']] = [ 'id' => $result['id'], 'name' => $result['name'], ]; } $out[$result['id']]['products'][] = [ 'pId' => $result['pId'], 'anzahl' => $result['anzahl'], 'pName' => $result['pName'], 'preis' => $result['preis'], ]; } print_r(array_values($out));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 29
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/q0jN4
function name:  (null)
number of ops:  37
compiled vars:  !0 = $results, !1 = $out, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
   32     1        ASSIGN                                                   !1, <array>
   33     2      > FE_RESET_R                                       $5      !0, ->29
          3    > > FE_FETCH_R                                               $5, !2, ->29
   35     4    >   FETCH_DIM_R                                      ~6      !2, 'id'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, ~6
          6        BOOL_NOT                                         ~8      ~7
          7      > JMPZ                                                     ~8, ->15
   36     8    >   FETCH_DIM_R                                      ~9      !2, 'id'
   37     9        FETCH_DIM_R                                      ~11     !2, 'id'
         10        INIT_ARRAY                                       ~12     ~11, 'id'
   38    11        FETCH_DIM_R                                      ~13     !2, 'name'
         12        ADD_ARRAY_ELEMENT                                ~12     ~13, 'name'
   36    13        ASSIGN_DIM                                               !1, ~9
   38    14        OP_DATA                                                  ~12
   42    15    >   FETCH_DIM_R                                      ~14     !2, 'id'
   43    16        FETCH_DIM_R                                      ~18     !2, 'pId'
         17        INIT_ARRAY                                       ~19     ~18, 'pId'
   44    18        FETCH_DIM_R                                      ~20     !2, 'anzahl'
         19        ADD_ARRAY_ELEMENT                                ~19     ~20, 'anzahl'
   45    20        FETCH_DIM_R                                      ~21     !2, 'pName'
         21        ADD_ARRAY_ELEMENT                                ~19     ~21, 'pName'
   46    22        FETCH_DIM_R                                      ~22     !2, 'preis'
         23        ADD_ARRAY_ELEMENT                                ~19     ~22, 'preis'
   42    24        FETCH_DIM_W                                      $15     !1, ~14
         25        FETCH_DIM_W                                      $16     $15, 'products'
         26        ASSIGN_DIM                                               $16
   46    27        OP_DATA                                                  ~19
   33    28      > JMP                                                      ->3
         29    >   FE_FREE                                                  $5
   49    30        INIT_FCALL                                               'print_r'
         31        INIT_FCALL                                               'array_values'
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                         $23     
         34        SEND_VAR                                                 $23
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.08 ms | 1401 KiB | 17 Q