3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myarray = array( array( 0 => 0, 1 => 70, 2 => 19, 3 => 0 ), array( 0 => 0, 1 => 24, 2 => 14 ), array( 0 => 0, 1 => 15, 2 => 11, 3 => 0 ), array( 0 => 0, 1 => 15, 2 => 27, 3 => 0 ) ); foreach($myarray as $k => $values) { if (isset($myarray[$k+1])){ $max = max(sizeof($values), sizeof($myarray[$k+1])); for($i = 0; $i < $max; ++$i) { $result[$k][$i] = (isset($values[$i]) ? $values[$i] : 0) - (isset($myarray[$k+1][$i]) ? $myarray[$k+1][$i] : 0); } } else { $result[$k] = $values; } } var_export($result);
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
array ( 0 => array ( 0 => 0, 1 => 46, 2 => 5, 3 => 0, ), 1 => array ( 0 => 0, 1 => 9, 2 => 3, 3 => 0, ), 2 => array ( 0 => 0, 1 => 0, 2 => -16, 3 => 0, ), 3 => array ( 0 => 0, 1 => 15, 2 => 27, 3 => 0, ), )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 array ( 0 => array ( 0 => 0, 1 => 46, 2 => 5, 3 => 0, ), 1 => array ( 0 => 0, 1 => 9, 2 => 3, 3 => 0, ), 2 => array ( 0 => 0, 1 => 0, 2 => -16, 3 => 0, ), 3 => array ( 0 => 0, 1 => 15, 2 => 27, 3 => 0, ), )

preferences:
183.49 ms | 402 KiB | 172 Q