3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stats=[ ['statname'=>'foo', 'totalStatPower'=>1], ['statname'=>'bar', 'totalStatPower'=>2], ['statname'=>'foo', 'totalStatPower'=>3], ]; $totals = array_reduce( $stats, function( $a, $b ) { $a[ $b['statname'] ] += $b['totalStatPower']; return $a; }, [] ); var_dump( $totals );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UOkln
function name:  (null)
number of ops:  12
compiled vars:  !0 = $stats, !1 = $totals
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FUOkln%3A8%240'
          4        SEND_VAL                                                 ~3
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !1, $4
   10     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FUOkln%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UOkln
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !1, 'statname'
          3        FETCH_DIM_R                                      ~4      !1, 'totalStatPower'
          4        ASSIGN_DIM_OP                +=               1          !0, ~2
          5        OP_DATA                                                  ~4
          6      > RETURN                                                   !0
          7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FUOkln%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.62 ms | 1400 KiB | 17 Q