Copyright © tutorialspoint.com
| shuffle( $array ); |
This function shuffles (randomizes the order of the elements in) an array.
This function assigns new keys for the elements in array. It will remove any existing keys you may have assigned, rather than just reordering the keys.
| Parameter | Description |
|---|---|
| array | Required. Specifies an array. |
Returns TRUE on success or FALSE on failure.
Try out following example:
<?php
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana" );
shuffle($fruits);
print_r($fruits);
?>
|
This will produce following result. This result will vary everytime yoiu will shuffle an array.
Array ( [0] => banana [1] => orange [2] => lemon ) |
Copyright © tutorialspoint.com