3v4l.org

run code in 300+ PHP versions simultaneously
<?php $weight_distribution = [ '5' => 0, '10' => 6, '15' => 7, '20' => 3, ]; function distribute_weights($weight, &$distribution) { while ($weight > 0) { foreach ($distribution as $max => $count) { if ($weight <= $max) { break; } } ++$distribution[$max]; $weight -= $max; } } distribute_weights(21, $weight_distribution); var_export($weight_distribution);
Output for git.master_jit, git.master, rfc.property-hooks
array ( 5 => 1, 10 => 6, 15 => 7, 20 => 4, )

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:
67.19 ms | 405 KiB | 5 Q