3v4l.org

run code in 300+ PHP versions simultaneously
<?php function knapsackLight($value1, $weight1, $value2, $weight2, $maxW) { $results[0] = $maxW >= $weight1 && $value1 ? $value1 : null; $results[1] = $maxW >= $weight2 && $value2 ? $value2 : null; $results[2] = $maxW >= $weight1 + $weight2 && $value1 + $value2 ? $value1 + $value2 : null; return max($results[0], $results[1], $results[2]); } var_dump(knapsackLight(10, 5, 6, 4, 8)); var_dump(knapsackLight(10, 5, 6, 5, 9));
Output for git.master, git.master_jit, rfc.property-hooks
int(10) int(10)

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