3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php foreach (range(1, 100) as $num) { if (!($num % 15)) { echo 'FizzBuzz' . PHP_EOL; } elseif (!($num % 5)) { echo 'Buzz' . PHP_EOL; } elseif (!($num % 3)) { echo 'Fizz' . PHP_EOL; } else { echo $num . PHP_EOL; } } $i = 0; foreach (range(1, 100) as $num) { $i++; if (in_array($i, [1, 2, 4, 7, 8, 11, 14])) { echo $num . PHP_EOL; } elseif (in_array($i, [3, 6, 9, 12])) { echo 'Fizz' . PHP_EOL; } elseif (in_array($i, [5, 10])) { echo 'Buzz' . PHP_EOL; } elseif ($i = 15) { echo 'FizzBuzz' . PHP_EOL; $i = 0; } }
based on P6GCl
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz 28 29 FizzBuzz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz 61 62 Fizz 64 Buzz Fizz 67 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77 Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz 91 92 Fizz 94 Buzz Fizz 97 98 Fizz Buzz 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz FizzBuzz 14 15 Fizz 17 Buzz Fizz 20 21 Fizz Buzz 24 Fizz FizzBuzz 27 28 Fizz 30 Buzz Fizz 33 34 Fizz Buzz 37 Fizz FizzBuzz 40 41 Fizz 43 Buzz Fizz 46 47 Fizz Buzz 50 Fizz FizzBuzz 53 54 Fizz 56 Buzz Fizz 59 60 Fizz Buzz 63 Fizz FizzBuzz 66 67 Fizz 69 Buzz Fizz 72 73 Fizz Buzz 76 Fizz FizzBuzz 79 80 Fizz 82 Buzz Fizz 85 86 Fizz Buzz 89 Fizz FizzBuzz 92 93 Fizz 95 Buzz Fizz 98 99 Fizz
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/VI8ll on line 18
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/VI8ll on line 18
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/VI8ll on line 18
Process exited with code 255.