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)); $subtract = 3.5; foreach($val as $item){ foreach($item as $key => $items) { if ($subtract > $items){ $subtract -= $items; $item[$key] = 0; } else{ $item[$key] -= $subtract; $subtract = 0; } } print_r($item); }
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [price] => 696.5 ) Array ( [price] => 1000 ) Array ( [price] => 2000 ) Array ( [price] => 30000 ) Array ( [price] => 2000 )

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:
44.69 ms | 401 KiB | 8 Q