3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $players = range(1, 32); $count = count($players); // Order players. for ($i = 0; $i < log($count / 2, 2); $i++) { $out = array(); foreach ($players as $player) { $splice = pow(2, $i); $out = array_merge($out, array_splice($players, 0, $splice)); $out = array_merge($out, array_splice($players, -$splice)); } $players = $out; } // Print match list. for ($i = 0; $i < $count; $i++) { printf('%s vs %s<br />%s', $players[$i], $players[++$i], PHP_EOL); } ?>
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
1 vs 32<br /> 16 vs 17<br /> 8 vs 25<br /> 9 vs 24<br /> 4 vs 29<br /> 13 vs 20<br /> 5 vs 28<br /> 12 vs 21<br /> 2 vs 31<br /> 15 vs 18<br /> 7 vs 26<br /> 10 vs 23<br /> 3 vs 30<br /> 14 vs 19<br /> 6 vs 27<br /> 11 vs 22<br />
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 1 vs 32<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 16 vs 17<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 8 vs 25<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 9 vs 24<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 4 vs 29<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 13 vs 20<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 5 vs 28<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 12 vs 21<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 2 vs 31<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 15 vs 18<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 7 vs 26<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 10 vs 23<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 3 vs 30<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 14 vs 19<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 6 vs 27<br />PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/NOhsp on line 22 11 vs 22<br />PHP_EOL