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'] ]; $default = array_fill_keys(['subscribers', 'unsubscribers'], 0); var_export( array_values( array_reduce( array_merge($array1, $array2), function($result, $row) use($default) { $result[$row['dt_date']] = array_merge($result[$row['dt_date']] ?? $default, $row); return $result; } ) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6rUeW
function name:  (null)
number of ops:  24
compiled vars:  !0 = $array1, !1 = $array2, !2 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   13     2        INIT_FCALL                                               'array_fill_keys'
          3        SEND_VAL                                                 <array>
          4        SEND_VAL                                                 0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
   14     7        INIT_FCALL                                               'var_export'
   15     8        INIT_FCALL                                               'array_values'
   16     9        INIT_FCALL                                               'array_reduce'
   17    10        INIT_FCALL                                               'array_merge'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $7      
         14        SEND_VAR                                                 $7
   18    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6rUeW%3A18%240'
         16        BIND_LEXICAL                                             ~8, !2
   21    17        SEND_VAL                                                 ~8
         18        DO_ICALL                                         $9      
         19        SEND_VAR                                                 $9
         20        DO_ICALL                                         $10     
         21        SEND_VAR                                                 $10
         22        DO_ICALL                                                 
   24    23      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2F6rUeW%3A18%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.07 ms | 1412 KiB | 23 Q