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 );

preferences:
54.78 ms | 402 KiB | 5 Q