3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = [ 1 => [ ['id' => 491, 'default' => false], ['id' => 492, 'default' => false], ['id' => 493, 'default' => true], ], 2 => [ ['id' => 491, 'default' => false], ['id' => 492, 'default' => true], ['id' => 493, 'default' => false], ['id' => 494, 'default' => false], ], ]; $id = 'id'; $result = array_column($data[1], null, $id) + array_column($data[2], null, $id) ; print_r($result); print_r(array_values($result));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2Lk8R
function name:  (null)
number of ops:  26
compiled vars:  !0 = $data, !1 = $id, !2 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   18     1        ASSIGN                                                       !1, 'id'
   20     2        INIT_FCALL                                                   'array_column'
          3        FETCH_DIM_R                                          ~5      !0, 1
          4        SEND_VAL                                                     ~5
          5        SEND_VAL                                                     null
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                             $6      
   21     8        INIT_FCALL                                                   'array_column'
          9        FETCH_DIM_R                                          ~7      !0, 2
         10        SEND_VAL                                                     ~7
         11        SEND_VAL                                                     null
         12        SEND_VAR                                                     !1
         13        DO_ICALL                                             $8      
         14        ADD                                                  ~9      $6, $8
   20    15        ASSIGN                                                       !2, ~9
   24    16        INIT_FCALL                                                   'print_r'
         17        SEND_VAR                                                     !2
         18        DO_ICALL                                                     
   25    19        INIT_FCALL                                                   'print_r'
         20        INIT_FCALL                                                   'array_values'
         21        SEND_VAR                                                     !2
         22        DO_ICALL                                             $12     
         23        SEND_VAR                                                     $12
         24        DO_ICALL                                                     
         25      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.57 ms | 3624 KiB | 16 Q