- var_dump: documentation ( source)
- array_values: documentation ( source)
- implode: documentation ( source)
- rand: documentation ( source)
<?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);