3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Lets create a dummy array $array = array(); for($i = 0; $i < 1000; $i++) { $array[] = $i; } // Lets make a randomized temporary array $backUpArray = $array; $tempArray = array(); for($i = 0; $i < 50; $i++) { // Select random Index $randomIndex = rand(0 , count($backUpArray)); // Copy it to the temp array $tempArray[] = $backUpArray[$randomIndex]; // Delete the row from our backup unset($backUpArray[$randomIndex]); // Reorganize the key indexes $backUpArray = array_values($backUpArray); } $string1 = implode(",", $tempArray); var_dump($string1);

preferences:
25.79 ms | 407 KiB | 5 Q