3v4l.org

run code in 300+ PHP versions simultaneously
<?php $total_capacity = 100; $resources = array('gold'=>125,'stone'=>30, 'food'=>0); $loot = array(); asort($resources); foreach($resources as $type => $resource) { $max = floor(($total_capacity-array_sum($loot))/(3-count($loot))); // var_dump(count($loot)); if($max > $resource) { $loot[$type] = $resource; } else { $loot[$type] = $max; } } print_r($loot); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [food] => 0 [stone] => 30 [gold] => 70 )

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