3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ ['subscribers' => 2, 'dt_date' => '2014-02-27'], ['subscribers' => 2, 'dt_date' => '2014-02-25'], ['subscribers' => 1, 'dt_date' => '2014-02-07'] ]; $array2 = [ ['unsubscribers' => 1, 'dt_date' => '2014-02-27'], ['unsubscribers' => 1, 'dt_date' => '2014-02-01'] ]; $result = []; $default = array_fill_keys(['subscribers', 'unsubscribers'], 0); foreach (array_merge($array1, $array2) as $row) { $result[$row['dt_date']] = array_merge($result[$row['dt_date']] ?? $default, $row); } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 26
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/fUaaJ
function name:  (null)
number of ops:  34
compiled vars:  !0 = $array1, !1 = $array2, !2 = $result, !3 = $default, !4 = $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_fill_keys'
          4        SEND_VAL                                                 <array>
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !3, $8
   15     8        INIT_FCALL                                               'array_merge'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $10     
         12      > FE_RESET_R                                       $11     $10, ->26
         13    > > FE_FETCH_R                                               $11, !4, ->26
   16    14    >   FETCH_DIM_R                                      ~12     !4, 'dt_date'
         15        INIT_FCALL                                               'array_merge'
         16        FETCH_DIM_R                                      ~14     !4, 'dt_date'
         17        FETCH_DIM_IS                                     ~15     !2, ~14
         18        COALESCE                                         ~16     ~15
         19        QM_ASSIGN                                        ~16     !3
         20        SEND_VAL                                                 ~16
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                         $17     
         23        ASSIGN_DIM                                               !2, ~12
         24        OP_DATA                                                  $17
   15    25      > JMP                                                      ->13
         26    >   FE_FREE                                                  $11
   18    27        INIT_FCALL                                               'var_export'
         28        INIT_FCALL                                               'array_values'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                         $18     
         31        SEND_VAR                                                 $18
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.6 ms | 1409 KiB | 21 Q