3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $low=0; $high=100; $args=getopt( "l:h:"); foreach($args as $k=>$v) { switch($k) { case 'h': $high=intval($v); break; case 'l': $low=intval($v); break; default: echo(" Unknown value $k=>$v"); } } var_dump(calculate($low, $high)); function calculate($low, $high) { $out=array(); for($i=$low; $i<=$high; $i++) { switch($i) { case ($i % 3 ==0) && ($i % 5==0) : $out[$i]="Fizzbuzz"; break; case ($i % 3==0) : $out[$i]="Fizz"; break; case ($i % 5==0) : $out[$i]="Buzz"; break; default: $out[$i]="".$i; } } return $out; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(101) { [0]=> string(1) "0" [1]=> string(1) "1" [2]=> string(1) "2" [3]=> string(4) "Fizz" [4]=> string(1) "4" [5]=> string(4) "Buzz" [6]=> string(4) "Fizz" [7]=> string(1) "7" [8]=> string(1) "8" [9]=> string(4) "Fizz" [10]=> string(4) "Buzz" [11]=> string(2) "11" [12]=> string(4) "Fizz" [13]=> string(2) "13" [14]=> string(2) "14" [15]=> string(8) "Fizzbuzz" [16]=> string(2) "16" [17]=> string(2) "17" [18]=> string(4) "Fizz" [19]=> string(2) "19" [20]=> string(4) "Buzz" [21]=> string(4) "Fizz" [22]=> string(2) "22" [23]=> string(2) "23" [24]=> string(4) "Fizz" [25]=> string(4) "Buzz" [26]=> string(2) "26" [27]=> string(4) "Fizz" [28]=> string(2) "28" [29]=> string(2) "29" [30]=> string(8) "Fizzbuzz" [31]=> string(2) "31" [32]=> string(2) "32" [33]=> string(4) "Fizz" [34]=> string(2) "34" [35]=> string(4) "Buzz" [36]=> string(4) "Fizz" [37]=> string(2) "37" [38]=> string(2) "38" [39]=> string(4) "Fizz" [40]=> string(4) "Buzz" [41]=> string(2) "41" [42]=> string(4) "Fizz" [43]=> string(2) "43" [44]=> string(2) "44" [45]=> string(8) "Fizzbuzz" [46]=> string(2) "46" [47]=> string(2) "47" [48]=> string(4) "Fizz" [49]=> string(2) "49" [50]=> string(4) "Buzz" [51]=> string(4) "Fizz" [52]=> string(2) "52" [53]=> string(2) "53" [54]=> string(4) "Fizz" [55]=> string(4) "Buzz" [56]=> string(2) "56" [57]=> string(4) "Fizz" [58]=> string(2) "58" [59]=> string(2) "59" [60]=> string(8) "Fizzbuzz" [61]=> string(2) "61" [62]=> string(2) "62" [63]=> string(4) "Fizz" [64]=> string(2) "64" [65]=> string(4) "Buzz" [66]=> string(4) "Fizz" [67]=> string(2) "67" [68]=> string(2) "68" [69]=> string(4) "Fizz" [70]=> string(4) "Buzz" [71]=> string(2) "71" [72]=> string(4) "Fizz" [73]=> string(2) "73" [74]=> string(2) "74" [75]=> string(8) "Fizzbuzz" [76]=> string(2) "76" [77]=> string(2) "77" [78]=> string(4) "Fizz" [79]=> string(2) "79" [80]=> string(4) "Buzz" [81]=> string(4) "Fizz" [82]=> string(2) "82" [83]=> string(2) "83" [84]=> string(4) "Fizz" [85]=> string(4) "Buzz" [86]=> string(2) "86" [87]=> string(4) "Fizz" [88]=> string(2) "88" [89]=> string(2) "89" [90]=> string(8) "Fizzbuzz" [91]=> string(2) "91" [92]=> string(2) "92" [93]=> string(4) "Fizz" [94]=> string(2) "94" [95]=> string(4) "Buzz" [96]=> string(4) "Fizz" [97]=> string(2) "97" [98]=> string(2) "98" [99]=> string(4) "Fizz" [100]=> string(4) "Buzz" }