Syntax
shuffle( $array ); |
Definition and Usage
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.
Paramters
Parameter | Description |
---|---|
array | Required. Specifies an array. |
Return Value
Returns TRUE on success or FALSE on failure.
Example
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 ) |
No comments:
Post a Comment