3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array1 = [ [ "total_process_per_category" => "6", "category_id" => "1" ], [ "total_process_per_category" => "2", "category_id" => "2" ] ]; $array2 = [ [ "total_pinned_per_category" => "16", "category_id" => "1" ], [ "total_pinned_per_category" => "4", "category_id" => "2" ] ]; $result = []; foreach (array_merge($array1, $array2) as $row) { $result[$row['category_id']] = ($result[$row['category_id']] ?? []) + $row; } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/1lu5T
function name:  (null)
number of ops:  26
compiled vars:  !0 = $array1, !1 = $array2, !2 = $result, !3 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   14     1        ASSIGN                                                       !1, <array>
   25     2        ASSIGN                                                       !2, <array>
   26     3        INIT_FCALL                                                   'array_merge'
          4        SEND_VAR                                                     !0
          5        SEND_VAR                                                     !1
          6        DO_ICALL                                             $7      
          7      > FE_RESET_R                                           $8      $7, ->18
          8    > > FE_FETCH_R                                                   $8, !3, ->18
   27     9    >   FETCH_DIM_R                                          ~9      !3, 'category_id'
         10        FETCH_DIM_R                                          ~11     !3, 'category_id'
         11        FETCH_DIM_IS                                         ~12     !2, ~11
         12        COALESCE                                             ~13     ~12
         13        QM_ASSIGN                                            ~13     <array>
         14        ADD                                                  ~14     ~13, !3
         15        ASSIGN_DIM                                                   !2, ~9
         16        OP_DATA                                                      ~14
   26    17      > JMP                                                          ->8
         18    >   FE_FREE                                                      $8
   29    19        INIT_FCALL                                                   'var_export'
         20        INIT_FCALL                                                   'array_values'
         21        SEND_VAR                                                     !2
         22        DO_ICALL                                             $15     
         23        SEND_VAR                                                     $15
         24        DO_ICALL                                                     
         25      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.62 ms | 1905 KiB | 16 Q