3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = [ "A" => "dataA1", "B" => "dataB1", "C" => "dataC1"]; $arr2 = [ "A" => "dataA2", "C" => "dataC2", "D" => "dataD2"]; $out = array_reduce( array_unique(array_merge(array_keys($arr1), array_keys($arr2))), function($c, $k) use($arr1, $arr2) { $c[$k] = array_merge( [$arr1[$k] ?? null], [$arr2[$k] ?? null], ); return $c; }, [] ); var_dump($out);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cg86V
function name:  (null)
number of ops:  28
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'array_reduce'
    6     3        INIT_FCALL                                               'array_unique'
          4        INIT_FCALL                                               'array_merge'
          5        INIT_FCALL                                               'array_keys'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        SEND_VAR                                                 $5
          9        INIT_FCALL                                               'array_keys'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                         $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                         $8      
         16        SEND_VAR                                                 $8
    7    17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fcg86V%3A7%240'
         18        BIND_LEXICAL                                             ~9, !0
         19        BIND_LEXICAL                                             ~9, !1
   13    20        SEND_VAL                                                 ~9
   14    21        SEND_VAL                                                 <array>
         22        DO_ICALL                                         $10     
    5    23        ASSIGN                                                   !2, $10
   17    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fcg86V%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cg86V
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $c, !1 = $k, !2 = $arr1, !3 = $arr2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
    8     4        INIT_FCALL                                               'array_merge'
    9     5        FETCH_DIM_IS                                     ~5      !2, !1
          6        COALESCE                                         ~6      ~5
          7        QM_ASSIGN                                        ~6      null
          8        INIT_ARRAY                                       ~7      ~6
          9        SEND_VAL                                                 ~7
   10    10        FETCH_DIM_IS                                     ~8      !3, !1
         11        COALESCE                                         ~9      ~8
         12        QM_ASSIGN                                        ~9      null
         13        INIT_ARRAY                                       ~10     ~9
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                         $11     
    8    16        ASSIGN_DIM                                               !0, !1
   10    17        OP_DATA                                                  $11
   12    18      > RETURN                                                   !0
   13    19*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fcg86V%3A7%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
258.04 ms | 1400 KiB | 23 Q