3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 1 => [1 => 11, 2 => 21 ,3 => 31], 2 => [1 => 21, 2 => 22], 3 => [1 => 31, 2 => 23 ,3 => 32], ]; foreach ($data as $k => $row) { foreach ($row as $i => $v) { $data[$k]['Total'] = ($data[$k]['Total'] ?? 0) + $v; $data['Total'][$i] = ($data['Total'][$i] ?? 0) + $v; } $data['Total']['Total'] = ($data['Total']['Total'] ?? 0) + $data[$k]['Total']; } var_export($data);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 1 => array ( 1 => 11, 2 => 21, 3 => 31, 'Total' => 63, ), 2 => array ( 1 => 21, 2 => 22, 'Total' => 43, ), 3 => array ( 1 => 31, 2 => 23, 3 => 32, 'Total' => 86, ), 'Total' => array ( 1 => 63, 2 => 66, 3 => 63, 'Total' => 192, ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
84.03 ms | 406 KiB | 5 Q