3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ "partner_id" => "10017", "store_id" => "1000", "item_type_id" => "2", "value" => "58", "category" => "1" ], [ "partner_id" => "10017", "store_id" => "1000", "item_type_id" => "1", "value" => "63", "category" => "1" ], [ "partner_id" => "0", "store_id" => "1000", "item_type_id" => "3", "value" => "29", "category" => "1" ], [ "partner_id" => "0", "store_id" => "1000", "item_type_id" => "2", "value" => "58", "category" => "1" ], [ "partner_id" => "0", "store_id" => "1001", "item_type_id" => "1", "value" => "65", "category" => "1" ], [ "partner_id" => "0", "store_id" => "1001", "item_type_id" => "2", "value" => "58", "category" => "1" ], [ "partner_id" => "0", "store_id" => "1001", "item_type_id" => "3", "value" => "29", "category" => "1" ], [ "partner_id" => "0", "store_id" => "1000", "item_type_id" => "1", "value" => "65", "category" => "1" ] ]; $result = []; foreach ($array as $row) { if ($row['partner_id'] || !isset($result[$row['store_id']][$row['item_type_id']])) { $result[$row['store_id']][$row['item_type_id']][$row['partner_id']] = $row; } } var_export(array_map(function($row) { return array_merge(...$row); }, $result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
Branch analysis from position: 12
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/EN4dN
function name:  (null)
number of ops:  31
compiled vars:  !0 = $array, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   62     1        ASSIGN                                                   !1, <array>
   63     2      > FE_RESET_R                                       $5      !0, ->21
          3    > > FE_FETCH_R                                               $5, !2, ->21
   64     4    >   FETCH_DIM_R                                      ~6      !2, 'partner_id'
          5      > JMPNZ_EX                                         ~6      ~6, ->12
          6    >   FETCH_DIM_R                                      ~7      !2, 'store_id'
          7        FETCH_DIM_R                                      ~9      !2, 'item_type_id'
          8        FETCH_DIM_IS                                     ~8      !1, ~7
          9        ISSET_ISEMPTY_DIM_OBJ                         0  ~10     ~8, ~9
         10        BOOL_NOT                                         ~11     ~10
         11        BOOL                                             ~6      ~11
         12    > > JMPZ                                                     ~6, ->20
   65    13    >   FETCH_DIM_R                                      ~12     !2, 'store_id'
         14        FETCH_DIM_R                                      ~14     !2, 'item_type_id'
         15        FETCH_DIM_R                                      ~16     !2, 'partner_id'
         16        FETCH_DIM_W                                      $13     !1, ~12
         17        FETCH_DIM_W                                      $15     $13, ~14
         18        ASSIGN_DIM                                               $15, ~16
         19        OP_DATA                                                  !2
   63    20    > > JMP                                                      ->3
         21    >   FE_FREE                                                  $5
   68    22        INIT_FCALL                                               'var_export'
         23        INIT_FCALL                                               'array_map'
         24        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEN4dN%3A68%240'
         25        SEND_VAL                                                 ~18
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $19     
         28        SEND_VAR                                                 $19
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FEN4dN%3A68%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EN4dN
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'array_merge'
          2        SEND_UNPACK                                              !0
          3        CHECK_UNDEF_ARGS                                         
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEN4dN%3A68%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.58 ms | 1413 KiB | 19 Q