3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ ['quantity' => 5, 'dd' => '01-Nov-2012'], ['quantity' => 10, 'dd' => '01-Nov-2012'], ['quantity' => 3, 'dd' => '02-Nov-2012'], ['quantity' => 4, 'dd' => '03-Nov-2012'], ['quantity' => 15, 'dd' => '03-Nov-2012'], ]; var_export( array_reduce( $array, function($result, $row) { static $ref = []; if (!isset($ref[$row['dd']])) { $ref[$row['dd']] = $row; $result[] = &$ref[$row['dd']]; } else { $ref[$row['dd']]['quantity'] += $row['quantity']; } return $result; } ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N0pAC
function name:  (null)
number of ops:  10
compiled vars:  !0 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   11     1        INIT_FCALL                                                   'var_export'
   12     2        INIT_FCALL                                                   'array_reduce'
   13     3        SEND_VAR                                                     !0
   14     4        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
   23     5        SEND_VAL                                                     ~2
   12     6        DO_ICALL                                             $3      
   23     7        SEND_VAR                                                     $3
   11     8        DO_ICALL                                                     
   25     9      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/N0pAC
function name:  {closure:/in/N0pAC:14}
number of ops:  23
compiled vars:  !0 = $result, !1 = $row, !2 = $ref
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   15     2        BIND_STATIC                                                  !2
   16     3        FETCH_DIM_R                                          ~3      !1, 'dd'
          4        ISSET_ISEMPTY_DIM_OBJ                             0  ~4      !2, ~3
          5        BOOL_NOT                                             ~5      ~4
          6      > JMPZ                                                         ~5, ->16
   17     7    >   FETCH_DIM_R                                          ~6      !1, 'dd'
          8        ASSIGN_DIM                                                   !2, ~6
          9        OP_DATA                                                      !1
   18    10        FETCH_DIM_R                                          ~9      !1, 'dd'
         11        FETCH_DIM_W                                          $10     !2, ~9
         12        MAKE_REF                                             $11     $10
         13        FETCH_DIM_W                                          $8      !0
         14        ASSIGN_REF                                                   $8, $11
   16    15      > JMP                                                          ->21
   20    16    >   FETCH_DIM_R                                          ~13     !1, 'dd'
         17        FETCH_DIM_R                                          ~16     !1, 'quantity'
         18        FETCH_DIM_RW                                         $14     !2, ~13
         19        ASSIGN_DIM_OP                    +=               1          $14, 'quantity'
         20        OP_DATA                                                      ~16
   22    21    > > RETURN                                                       !0
   23    22*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
189.58 ms | 1795 KiB | 15 Q