PHP shuffle function

WBOY
Release: 2016-07-29 09:14:23
Original
1361 people have browsed it

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)
Copy after login

Parameters Description
array Required. Specifies the array to use.

Example
<?php
$my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse");
shuffle($my_array);
print_r($my_array);
?>
Copy after login

Output:

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

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!