3v4l.org

run code in 300+ PHP versions simultaneously
<?php $maxMatches = 3; $matches = array('tails' => 0, 'heads' => 0, 'total' => 0); while(max($matches['tails'], $matches['heads']) < $maxMatches) { $faceType = rand(0, 1); if ($faceType) { $matches['heads']++; $matches['tails'] = 0; echo $faceType . " is heads\n"; } else { $matches['tails']++; $matches['heads'] = 0; echo $faceType." is tails\n"; } $matches['total']++; } echo "total flips took is: " . $matches['total'];

preferences:
28.5 ms | 402 KiB | 5 Q