3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['date' => '2017-08-22', 'AAA' => 1231], ['date' => '2017-08-21', 'AAA' => 1172], ['date' => '2017-08-20', 'AAA' => 1125], ['date' => '2017-08-21', 'BBB' => 251], ['date' => '2017-08-20', 'BBB' => 21773], ['date' => '2017-08-22', 'CCC' => 3750], ['date' => '2017-08-20', 'CCC' => 321750], ]; var_export( array_reduce( $array, function($accumulator, $row) { $date = $row['date']; unset($row['date']); $accumulator[$date] = array_merge($accumulator[$date] ?? [], $row); return $accumulator; }, [] ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cYLEg
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'var_export'
   14     2        INIT_FCALL                                               'array_reduce'
   15     3        SEND_VAR                                                 !0
   16     4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   21     5        SEND_VAL                                                 ~2
   22     6        SEND_VAL                                                 <array>
   14     7        DO_ICALL                                         $3      
   22     8        SEND_VAR                                                 $3
   13     9        DO_ICALL                                                 
   24    10      > 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/cYLEg
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $accumulator, !1 = $row, !2 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        FETCH_DIM_R                                      ~3      !1, 'date'
          3        ASSIGN                                                   !2, ~3
   18     4        UNSET_DIM                                                !1, 'date'
   19     5        INIT_FCALL                                               'array_merge'
          6        FETCH_DIM_IS                                     ~6      !0, !2
          7        COALESCE                                         ~7      ~6
          8        QM_ASSIGN                                        ~7      <array>
          9        SEND_VAL                                                 ~7
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $8      
         12        ASSIGN_DIM                                               !0, !2
         13        OP_DATA                                                  $8
   20    14      > RETURN                                                   !0
   21    15*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.04 ms | 1004 KiB | 16 Q