The shuffle() function rearranges the elements in the array in random order.
Returns TRUE if successful, otherwise returns FALSE.
Note: This function assigns a new key name to the unit in the array. This will delete the original keys rather than just reorder them.
Note: As of PHP 4.2.0, it is no longer necessary to seed the random number generator with the srand() or mt_srand() functions, it is now done automatically
$my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse");
shuffle($my_array);
print_r($my_array);
?>
Look at the following // Use an array to store the advertisement list
$ads = array(< ;/a>
,< ;/a>
,< ;/a>
,< ;/a>
);
// Randomly sort the array
shuffle($ads);
// Output the sorted array
$html = ;
foreach ($ads as $ad) {
$html .= $ad;
}
echo $html;