3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $weights = [1, 100, 111, 168, 569, 1652, 16549, 19999, 20000, 20001, 25649, 35216, 54961]; foreach($weights as $index => $weight) { $extra_weight = round($weight-20000, -3)/1000; $extra_cost = $extra_weight * 1.00; echo "Method 1: Weight= $weight , Extra Weight: $extra_weight \n"; echo "Method 1: Weight= $weight , Extra Cost: $extra_weight \n"; $extra_weight = round(($weight-20000)/1000, 0); $extra_cost = $extra_weight * 1.00; echo "Method 2: Weight= $weight , Extra Weight: $extra_weight \n"; echo "Method 2: Weight= $weight , Extra Cost: $extra_weight \n"; } ?>
based on NtNUH
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Method 1: Weight= 1 , Extra Weight: -20 Method 1: Weight= 1 , Extra Cost: -20 Method 2: Weight= 1 , Extra Weight: -20 Method 2: Weight= 1 , Extra Cost: -20 Method 1: Weight= 100 , Extra Weight: -20 Method 1: Weight= 100 , Extra Cost: -20 Method 2: Weight= 100 , Extra Weight: -20 Method 2: Weight= 100 , Extra Cost: -20 Method 1: Weight= 111 , Extra Weight: -20 Method 1: Weight= 111 , Extra Cost: -20 Method 2: Weight= 111 , Extra Weight: -20 Method 2: Weight= 111 , Extra Cost: -20 Method 1: Weight= 168 , Extra Weight: -20 Method 1: Weight= 168 , Extra Cost: -20 Method 2: Weight= 168 , Extra Weight: -20 Method 2: Weight= 168 , Extra Cost: -20 Method 1: Weight= 569 , Extra Weight: -19 Method 1: Weight= 569 , Extra Cost: -19 Method 2: Weight= 569 , Extra Weight: -19 Method 2: Weight= 569 , Extra Cost: -19 Method 1: Weight= 1652 , Extra Weight: -18 Method 1: Weight= 1652 , Extra Cost: -18 Method 2: Weight= 1652 , Extra Weight: -18 Method 2: Weight= 1652 , Extra Cost: -18 Method 1: Weight= 16549 , Extra Weight: -3 Method 1: Weight= 16549 , Extra Cost: -3 Method 2: Weight= 16549 , Extra Weight: -3 Method 2: Weight= 16549 , Extra Cost: -3 Method 1: Weight= 19999 , Extra Weight: -0 Method 1: Weight= 19999 , Extra Cost: -0 Method 2: Weight= 19999 , Extra Weight: -0 Method 2: Weight= 19999 , Extra Cost: -0 Method 1: Weight= 20000 , Extra Weight: 0 Method 1: Weight= 20000 , Extra Cost: 0 Method 2: Weight= 20000 , Extra Weight: 0 Method 2: Weight= 20000 , Extra Cost: 0 Method 1: Weight= 20001 , Extra Weight: 0 Method 1: Weight= 20001 , Extra Cost: 0 Method 2: Weight= 20001 , Extra Weight: 0 Method 2: Weight= 20001 , Extra Cost: 0 Method 1: Weight= 25649 , Extra Weight: 6 Method 1: Weight= 25649 , Extra Cost: 6 Method 2: Weight= 25649 , Extra Weight: 6 Method 2: Weight= 25649 , Extra Cost: 6 Method 1: Weight= 35216 , Extra Weight: 15 Method 1: Weight= 35216 , Extra Cost: 15 Method 2: Weight= 35216 , Extra Weight: 15 Method 2: Weight= 35216 , Extra Cost: 15 Method 1: Weight= 54961 , Extra Weight: 35 Method 1: Weight= 54961 , Extra Cost: 35 Method 2: Weight= 54961 , Extra Weight: 35 Method 2: Weight= 54961 , Extra Cost: 35
Output for hhvm-3.12.0
Method 1: Weight= 1 , Extra Weight: -20 Method 1: Weight= 1 , Extra Cost: -20 Method 2: Weight= 1 , Extra Weight: -20 Method 2: Weight= 1 , Extra Cost: -20 Method 1: Weight= 100 , Extra Weight: -20 Method 1: Weight= 100 , Extra Cost: -20 Method 2: Weight= 100 , Extra Weight: -20 Method 2: Weight= 100 , Extra Cost: -20 Method 1: Weight= 111 , Extra Weight: -20 Method 1: Weight= 111 , Extra Cost: -20 Method 2: Weight= 111 , Extra Weight: -20 Method 2: Weight= 111 , Extra Cost: -20 Method 1: Weight= 168 , Extra Weight: -20 Method 1: Weight= 168 , Extra Cost: -20 Method 2: Weight= 168 , Extra Weight: -20 Method 2: Weight= 168 , Extra Cost: -20 Method 1: Weight= 569 , Extra Weight: -19 Method 1: Weight= 569 , Extra Cost: -19 Method 2: Weight= 569 , Extra Weight: -19 Method 2: Weight= 569 , Extra Cost: -19 Method 1: Weight= 1652 , Extra Weight: -18 Method 1: Weight= 1652 , Extra Cost: -18 Method 2: Weight= 1652 , Extra Weight: -18 Method 2: Weight= 1652 , Extra Cost: -18 Method 1: Weight= 16549 , Extra Weight: -3 Method 1: Weight= 16549 , Extra Cost: -3 Method 2: Weight= 16549 , Extra Weight: -3 Method 2: Weight= 16549 , Extra Cost: -3 Method 1: Weight= 19999 , Extra Weight: 0 Method 1: Weight= 19999 , Extra Cost: 0 Method 2: Weight= 19999 , Extra Weight: 0 Method 2: Weight= 19999 , Extra Cost: 0 Method 1: Weight= 20000 , Extra Weight: 0 Method 1: Weight= 20000 , Extra Cost: 0 Method 2: Weight= 20000 , Extra Weight: 0 Method 2: Weight= 20000 , Extra Cost: 0 Method 1: Weight= 20001 , Extra Weight: 0 Method 1: Weight= 20001 , Extra Cost: 0 Method 2: Weight= 20001 , Extra Weight: 0 Method 2: Weight= 20001 , Extra Cost: 0 Method 1: Weight= 25649 , Extra Weight: 6 Method 1: Weight= 25649 , Extra Cost: 6 Method 2: Weight= 25649 , Extra Weight: 6 Method 2: Weight= 25649 , Extra Cost: 6 Method 1: Weight= 35216 , Extra Weight: 15 Method 1: Weight= 35216 , Extra Cost: 15 Method 2: Weight= 35216 , Extra Weight: 15 Method 2: Weight= 35216 , Extra Cost: 15 Method 1: Weight= 54961 , Extra Weight: 35 Method 1: Weight= 54961 , Extra Cost: 35 Method 2: Weight= 54961 , Extra Weight: 35 Method 2: Weight= 54961 , Extra Cost: 35
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/7Ho4b on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/7Ho4b on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/7Ho4b on line 3
Process exited with code 255.