3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @file A fizzbuzz reference implementation. * @author Brad Czerniak (ao5357@gmail.com) */ /** * Outputs fizzes and buzzes over a loop. * * @param int $iterations * The number of times to iterate over the loop * @param int $offset * The number to start at * @param string $fizz * The string to output for the first modulo condition, typically 'fizz'. * @param string $buzz * The string to output for the second modulo condition, typically 'buzz'. * @param string $fizzbuzz * The string to output for the third (usually combined) modulo condition, typically 'fizzbuzz'. * @param int $fizz_int * The first modulus * @param int $buzz_int * The second modulus * @param int $fizzbuzz_int * The third (usually combined) modulus * * @return An array of the loop's output */ function fizzbuzz($iterations = 100, $offset = 1, $fizz = 'fizz', $buzz = 'buzz', $fizzbuzz = 'fizzbuzz', $fizz_int = 3, $buzz_int = 5, $fizzbuzz_int = 15) { $i = $offset; $ret = array(); while($i < ($offset + $iterations)){ if($i % $fizzbuzz_int == 0){ $ret[] = $fizzbuzz;} elseif($i % $buzz_int == 0){ $ret[] = $buzz;} elseif($i % $fizz_int == 0){ $ret[] = $fizz;} else{ $ret[] = $i;} echo '$i = ' . $i . ' $offset = ' . $offset . ' $iterations = ' . $iterations . ' $ret this time is ' . $ret[($iterations - $offset - $i)]; $i++; } } print_r(fizzbuzz());
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 98 in /in/vZAC0 on line 37 $i = 1 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 97 in /in/vZAC0 on line 37 $i = 2 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 96 in /in/vZAC0 on line 37 $i = 3 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 95 in /in/vZAC0 on line 37 $i = 4 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 94 in /in/vZAC0 on line 37 $i = 5 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 93 in /in/vZAC0 on line 37 $i = 6 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 92 in /in/vZAC0 on line 37 $i = 7 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 91 in /in/vZAC0 on line 37 $i = 8 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 90 in /in/vZAC0 on line 37 $i = 9 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 89 in /in/vZAC0 on line 37 $i = 10 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 88 in /in/vZAC0 on line 37 $i = 11 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 87 in /in/vZAC0 on line 37 $i = 12 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 86 in /in/vZAC0 on line 37 $i = 13 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 85 in /in/vZAC0 on line 37 $i = 14 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 84 in /in/vZAC0 on line 37 $i = 15 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 83 in /in/vZAC0 on line 37 $i = 16 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 82 in /in/vZAC0 on line 37 $i = 17 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 81 in /in/vZAC0 on line 37 $i = 18 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 80 in /in/vZAC0 on line 37 $i = 19 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 79 in /in/vZAC0 on line 37 $i = 20 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 78 in /in/vZAC0 on line 37 $i = 21 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 77 in /in/vZAC0 on line 37 $i = 22 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 76 in /in/vZAC0 on line 37 $i = 23 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 75 in /in/vZAC0 on line 37 $i = 24 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 74 in /in/vZAC0 on line 37 $i = 25 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 73 in /in/vZAC0 on line 37 $i = 26 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 72 in /in/vZAC0 on line 37 $i = 27 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 71 in /in/vZAC0 on line 37 $i = 28 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 70 in /in/vZAC0 on line 37 $i = 29 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 69 in /in/vZAC0 on line 37 $i = 30 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 68 in /in/vZAC0 on line 37 $i = 31 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 67 in /in/vZAC0 on line 37 $i = 32 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 66 in /in/vZAC0 on line 37 $i = 33 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 65 in /in/vZAC0 on line 37 $i = 34 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 64 in /in/vZAC0 on line 37 $i = 35 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 63 in /in/vZAC0 on line 37 $i = 36 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 62 in /in/vZAC0 on line 37 $i = 37 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 61 in /in/vZAC0 on line 37 $i = 38 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 60 in /in/vZAC0 on line 37 $i = 39 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 59 in /in/vZAC0 on line 37 $i = 40 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 58 in /in/vZAC0 on line 37 $i = 41 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 57 in /in/vZAC0 on line 37 $i = 42 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 56 in /in/vZAC0 on line 37 $i = 43 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 55 in /in/vZAC0 on line 37 $i = 44 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 54 in /in/vZAC0 on line 37 $i = 45 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 53 in /in/vZAC0 on line 37 $i = 46 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 52 in /in/vZAC0 on line 37 $i = 47 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 51 in /in/vZAC0 on line 37 $i = 48 $offset = 1 $iterations = 100 $ret this time is Warning: Undefined array key 50 in /in/vZAC0 on line 37 $i = 49 $offset = 1 $iterations = 100 $ret this time is $i = 50 $offset = 1 $iterations = 100 $ret this time is buzz$i = 51 $offset = 1 $iterations = 100 $ret this time is 49$i = 52 $offset = 1 $iterations = 100 $ret this time is fizz$i = 53 $offset = 1 $iterations = 100 $ret this time is 47$i = 54 $offset = 1 $iterations = 100 $ret this time is 46$i = 55 $offset = 1 $iterations = 100 $ret this time is fizzbuzz$i = 56 $offset = 1 $iterations = 100 $ret this time is 44$i = 57 $offset = 1 $iterations = 100 $ret this time is 43$i = 58 $offset = 1 $iterations = 100 $ret this time is fizz$i = 59 $offset = 1 $iterations = 100 $ret this time is 41$i = 60 $offset = 1 $iterations = 100 $ret this time is buzz$i = 61 $offset = 1 $iterations = 100 $ret this time is fizz$i = 62 $offset = 1 $iterations = 100 $ret this time is 38$i = 63 $offset = 1 $iterations = 100 $ret this time is 37$i = 64 $offset = 1 $iterations = 100 $ret this time is fizz$i = 65 $offset = 1 $iterations = 100 $ret this time is buzz$i = 66 $offset = 1 $iterations = 100 $ret this time is 34$i = 67 $offset = 1 $iterations = 100 $ret this time is fizz$i = 68 $offset = 1 $iterations = 100 $ret this time is 32$i = 69 $offset = 1 $iterations = 100 $ret this time is 31$i = 70 $offset = 1 $iterations = 100 $ret this time is fizzbuzz$i = 71 $offset = 1 $iterations = 100 $ret this time is 29$i = 72 $offset = 1 $iterations = 100 $ret this time is 28$i = 73 $offset = 1 $iterations = 100 $ret this time is fizz$i = 74 $offset = 1 $iterations = 100 $ret this time is 26$i = 75 $offset = 1 $iterations = 100 $ret this time is buzz$i = 76 $offset = 1 $iterations = 100 $ret this time is fizz$i = 77 $offset = 1 $iterations = 100 $ret this time is 23$i = 78 $offset = 1 $iterations = 100 $ret this time is 22$i = 79 $offset = 1 $iterations = 100 $ret this time is fizz$i = 80 $offset = 1 $iterations = 100 $ret this time is buzz$i = 81 $offset = 1 $iterations = 100 $ret this time is 19$i = 82 $offset = 1 $iterations = 100 $ret this time is fizz$i = 83 $offset = 1 $iterations = 100 $ret this time is 17$i = 84 $offset = 1 $iterations = 100 $ret this time is 16$i = 85 $offset = 1 $iterations = 100 $ret this time is fizzbuzz$i = 86 $offset = 1 $iterations = 100 $ret this time is 14$i = 87 $offset = 1 $iterations = 100 $ret this time is 13$i = 88 $offset = 1 $iterations = 100 $ret this time is fizz$i = 89 $offset = 1 $iterations = 100 $ret this time is 11$i = 90 $offset = 1 $iterations = 100 $ret this time is buzz$i = 91 $offset = 1 $iterations = 100 $ret this time is fizz$i = 92 $offset = 1 $iterations = 100 $ret this time is 8$i = 93 $offset = 1 $iterations = 100 $ret this time is 7$i = 94 $offset = 1 $iterations = 100 $ret this time is fizz$i = 95 $offset = 1 $iterations = 100 $ret this time is buzz$i = 96 $offset = 1 $iterations = 100 $ret this time is 4$i = 97 $offset = 1 $iterations = 100 $ret this time is fizz$i = 98 $offset = 1 $iterations = 100 $ret this time is 2$i = 99 $offset = 1 $iterations = 100 $ret this time is 1 Warning: Undefined array key -1 in /in/vZAC0 on line 37 $i = 100 $offset = 1 $iterations = 100 $ret this time is

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:
52.53 ms | 421 KiB | 8 Q