3v4l.org

run code in 300+ PHP versions simultaneously
<?php $names = ['Adamino', 'Pete', 'Mark', 'Gonz']; $pairs = []; $iteration = 0; while (count($names) > 0) { ++$iteration; if ($iteration > 10) break; $plucked = array_rand($names, 2); $pair = [$names[$plucked[0]], $names[$plucked[1]]]; unset($names[$plucked[0]], $names[$plucked[1]]); $pairs[] = $pair; } $result = "The PP randomizer has selected: \n"; foreach ($pairs as $p) { $result .= " -> {$p[0]} and {$p[1]}\n"; }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.4.0

preferences:
86 ms | 402 KiB | 84 Q