Home>Article>Backend Development> PHP shuffle function

PHP shuffle function

WBOY
WBOY Original
2016-07-29 09:14:23 1355browse

Definition and Usage

shuffle() function rearranges the elements in the array in random order.

If successful, return TRUE, otherwise return 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() function, it is now done automatically.

Syntax
shuffle(array)

Parameters Description
array Required. Specifies the array to use.

Example
 "Dog", "b" => "Cat", "c" => "Horse"); shuffle($my_array); print_r($my_array); ?>

Output:

Array ( [0] => Cat [1] => Horse [2] => Dog )

The above has introduced the PHP shuffle function, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn