3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'url' => 'http://domain1.com', 'domain' => 'domain1.com', 'values' => ['character_length' => 25, 'word_count' => 7] ], [ 'url' => 'http://domain2.com', 'domain' => 'domain2.com', 'values' => ['character_length' => 30, 'word_count' => 7] ] ]; var_export( array_reduce( $array, function($result, $row) { $row['values']['character_length'] += ($result['values']['character_length'] ?? 0); $row['values']['word_count'] += ($result['values']['word_count'] ?? 0); return $row; } ) );
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array ( 'url' => 'http://domain2.com', 'domain' => 'domain2.com', 'values' => array ( 'character_length' => 55, 'word_count' => 14, ), )

preferences:
68.35 ms | 992 KiB | 4 Q