3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myarray = [ [0, 70, 19, 0], [0, 24, 14], // note missing 4th element [0, 15, 11, 0], [0, 15, 27, 0] ]; for ($i = sizeof($myarray)-2; $i>=0; --$i) { // start from 2nd last subarray, and move toward the start $max = max(sizeof($myarray[$i]), sizeof($myarray[$i+1])); // make sure all elements are accounted for for($k = 0; $k < $max; ++$k) { // iterate and perform subtractions / declarations $myarray[$i][$k] = (isset($myarray[$i][$k]) ? $myarray[$i][$k] : 0) - (isset($myarray[$i+1][$k]) ? $myarray[$i+1][$k] : 0); // declare/overwrite new values as encountered } } var_export($myarray);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 0 => 0, 1 => 46, 2 => -11, 3 => 0, ), 1 => array ( 0 => 0, 1 => 24, 2 => 30, 3 => 0, ), 2 => array ( 0 => 0, 1 => 0, 2 => -16, 3 => 0, ), 3 => array ( 0 => 0, 1 => 15, 2 => 27, 3 => 0, ), )

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:
33.38 ms | 402 KiB | 8 Q