3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [ ['rank' => '579', 'id' => '1'], ['rank' => '251', 'id' => '2'], ]; $b = [ ['size' => 'S', 'status' => 'A', 'id' => '1'], ['size' => 'L', 'status' => 'A', 'id' => '2'], ]; $result = []; foreach (array_merge($a, $b) as $row) { $result[$row['id']] = $row + ($result[$row['id']] ?? []); } 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/ncfvc
function name:  (null)
number of ops:  26
compiled vars:  !0 = $a, !1 = $b, !2 = $result, !3 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   13     2        ASSIGN                                                   !2, <array>
   14     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
   15     9    >   FETCH_DIM_R                                      ~9      !3, 'id'
         10        FETCH_DIM_R                                      ~11     !3, 'id'
         11        FETCH_DIM_IS                                     ~12     !2, ~11
         12        COALESCE                                         ~13     ~12
         13        QM_ASSIGN                                        ~13     <array>
         14        ADD                                              ~14     !3, ~13
         15        ASSIGN_DIM                                               !2, ~9
         16        OP_DATA                                                  ~14
   14    17      > JMP                                                      ->8
         18    >   FE_FREE                                                  $8
   17    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.0.0


preferences:
155.75 ms | 1395 KiB | 19 Q