3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'one', 'two', 'three', 'four' ]; $n = 10; $lastIndex = -1; $result = []; for ($x = 0; $x < $n; ++$x) { $key = array_rand(array_diff_key($array, [$lastIndex => null])); $result[] = $array[$key]; $lastIndex = $key; } echo PHP_EOL . json_encode($result);
Output for git.master
["three","four","two","one","three","two","four","two","three","one"]
Output for git.master_jit
["two","four","one","three","four","two","three","two","one","two"]

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:
46.81 ms | 406 KiB | 5 Q