3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ ['id' => 1,'name' => 'test1','desc' => 'test_desc','quantity' => 3], ['id' => 2,'name' => 'test2','desc' => 'test_desc','quantity' => 33] ]; $array2 = [ ['holder' => 'John','name' => 'test1','desc' => 'test_desc','location' => 'ATL'], ['holder' => 'Jackie','name' => 'test3','desc' => 'test_desc','location' => 'SF'] ]; $result = []; foreach (array_merge($array1, $array2) as $row) { if (!isset($ref[$row['name']])) { $ref[$row['name']] = $row; $result[] =& $ref[$row['name']]; } else { $ref[$row['name']] += $row; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 22
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/ernqk
function name:  (null)
number of ops:  31
compiled vars:  !0 = $array1, !1 = $array2, !2 = $result, !3 = $row, !4 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, <array>
   12     2        ASSIGN                                                   !2, <array>
   13     3        INIT_FCALL                                               'array_merge'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $8      
          7      > FE_RESET_R                                       $9      $8, ->26
          8    > > FE_FETCH_R                                               $9, !3, ->26
   14     9    >   FETCH_DIM_R                                      ~10     !3, 'name'
         10        ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !4, ~10
         11        BOOL_NOT                                         ~12     ~11
         12      > JMPZ                                                     ~12, ->22
   15    13    >   FETCH_DIM_R                                      ~13     !3, 'name'
         14        ASSIGN_DIM                                               !4, ~13
         15        OP_DATA                                                  !3
   16    16        FETCH_DIM_R                                      ~16     !3, 'name'
         17        FETCH_DIM_W                                      $17     !4, ~16
         18        MAKE_REF                                         $18     $17
         19        FETCH_DIM_W                                      $15     !2
         20        ASSIGN_REF                                               $15, $18
   14    21      > JMP                                                      ->25
   18    22    >   FETCH_DIM_R                                      ~20     !3, 'name'
         23        ASSIGN_DIM_OP                +=               1          !4, ~20
         24        OP_DATA                                                  !3
   13    25    > > JMP                                                      ->8
         26    >   FE_FREE                                                  $9
   21    27        INIT_FCALL                                               'var_export'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.16 ms | 1012 KiB | 15 Q