3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $val = array(array('price' => 700),array('price' => 1000),array('price' => 2000),array('price' => 30000),array('price' => 2000)); print_r($val); $subtract = 3.5; foreach($val as $key => $item){ if ($subtract > $item){ $subtract -= $item; $val[$key] = 0; } else{ $val[$key] -= $subtract; $subtract = 0; } } print_r($val);
Output for 7.0.0 - 7.3.0rc3
Array ( [0] => Array ( [price] => 700 ) [1] => Array ( [price] => 1000 ) [2] => Array ( [price] => 2000 ) [3] => Array ( [price] => 30000 ) [4] => Array ( [price] => 2000 ) ) Fatal error: Uncaught Error: Unsupported operand types in /in/89143:12 Stack trace: #0 {main} thrown in /in/89143 on line 12
Process exited with code 255.
Output for hhvm-3.22.0
Array ( [0] => Array ( [price] => 700 ) [1] => Array ( [price] => 1000 ) [2] => Array ( [price] => 2000 ) [3] => Array ( [price] => 30000 ) [4] => Array ( [price] => 2000 ) ) Fatal error: Invalid operand type was used: cannot perform this operation with arrays in /in/89143 on line -1
Process exited with code 255.
Output for hhvm-3.15.4 - 3.21.3
Array ( [0] => Array ( [price] => 700 ) [1] => Array ( [price] => 1000 ) [2] => Array ( [price] => 2000 ) [3] => Array ( [price] => 30000 ) [4] => Array ( [price] => 2000 ) ) Fatal error: Invalid operand type was used: cannot perform this operation with arrays in /in/89143 on line 12
Process exited with code 255.
Output for 5.6.30
Array ( [0] => Array ( [price] => 700 ) [1] => Array ( [price] => 1000 ) [2] => Array ( [price] => 2000 ) [3] => Array ( [price] => 30000 ) [4] => Array ( [price] => 2000 ) ) Fatal error: Unsupported operand types in /in/89143 on line 12
Process exited with code 255.