3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar1 = array( (object) array('id' => '1505', 'category' => 'blue'), (object) array('id' => '1805', 'category' => 'red') ); $ar2 = array( '1777' => (object) array('id' => '1505', 'category' => 'yellow'), '1877' => (object) array('id' => '1507', 'category' => 'blue'), ); $ids = array_column($ar1, 'id'); $ar3 = array_merge_recursive($ar1, array_filter($ar2, function($x) use ($ids) { return !in_array($x->id, $ids); })); print_r($ar3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SB4un
function name:  (null)
number of ops:  30
compiled vars:  !0 = $ar1, !1 = $ar2, !2 = $ids, !3 = $ar3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   CAST                                          8  ~4      <array>
          1        INIT_ARRAY                                       ~5      ~4
          2        CAST                                          8  ~6      <array>
          3        ADD_ARRAY_ELEMENT                                ~5      ~6
          4        ASSIGN                                                   !0, ~5
    4     5        CAST                                          8  ~8      <array>
          6        INIT_ARRAY                                       ~9      ~8, 1777
          7        CAST                                          8  ~10     <array>
          8        ADD_ARRAY_ELEMENT                                ~9      ~10, 1877
          9        ASSIGN                                                   !1, ~9
    5    10        INIT_FCALL                                               'array_column'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 'id'
         13        DO_ICALL                                         $12     
         14        ASSIGN                                                   !2, $12
    6    15        INIT_FCALL                                               'array_merge_recursive'
         16        SEND_VAR                                                 !0
         17        INIT_FCALL                                               'array_filter'
         18        SEND_VAR                                                 !1
         19        DECLARE_LAMBDA_FUNCTION                          ~14     [0]
         20        BIND_LEXICAL                                             ~14, !2
    8    21        SEND_VAL                                                 ~14
    6    22        DO_ICALL                                         $15     
    8    23        SEND_VAR                                                 $15
    6    24        DO_ICALL                                         $16     
         25        ASSIGN                                                   !3, $16
   10    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                                 
         29      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SB4un
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $x, !1 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        INIT_FCALL                                               'in_array'
          3        FETCH_OBJ_R                                      ~2      !0, 'id'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > RETURN                                                   ~4
    8     9*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.15 ms | 1011 KiB | 18 Q