3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [price] => 700 ) [1] => Array ( [price] => 1000 ) [2] => Array ( [price] => 2000 ) [3] => Array ( [price] => 30000 ) [4] => Array ( [price] => 2000 ) ) Fatal error: Uncaught TypeError: Unsupported operand types: array - float in /in/89143:12 Stack trace: #0 {main} thrown in /in/89143 on line 12
Process exited with code 255.

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