3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $items=23; $shortP = $items %10; $numP = ($items - $shortP) / 10 + 1; $extraI = $items - $numP; echo "There are $items items\n"; echo "They fit in $numP packages\n"; echo "Shipping cost is:\n"; echo " $numP * each_first cost\n"; echo " $extraI * each_next cost\n"; $ei = $items; $np = ($items - $ei) / 10 + 1; echo "cost = base * $np + next * " . ($items - $np) . "\n"; ?>
based on PIPsf
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0rc3
There are 23 items They fit in 3 packages Shipping cost is: 3 * each_first cost 20 * each_next cost cost = base * 1 + next * 22