<?php $array = [ 'one', 'two', 'three', 'four' ]; $n = 10; $lastIndex = -1; $result = []; for ($x = 0; $x < $n; ++$x) { $copy = $array; unset($copy[$lastIndex]); $key = array_rand($copy); $result[] = $copy[$key]; $lastIndex = $key; } echo PHP_EOL . json_encode($result);
You have javascript disabled. You will not be able to edit any code.