Home > Backend Development > PHP Tutorial > Implementation method of random sorting of php array_PHP tutorial

Implementation method of random sorting of php array_PHP tutorial

WBOY
Release: 2016-07-13 09:50:49
Original
967 people have browsed it

How to implement random sorting of php arrays

This article describes the implementation method of random sorting of php arrays. Share it with everyone for your reference. The specific implementation method is as follows:

1

2

3

4

5

$array = array('A','2','3','4','5','6','7','8','9','10','J','Q','K');

shuffle($array); //随机排序数组

print_r($array); //输出数组

?>

1 2

3

4

5

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

Array

(

[0] => Q

[1] => 3

[2] => 5

[3] => 2

[4] => 10

[5] => 9

[6] => K

[7] => 4

[8] => J

[9] => 6

[10] => 7

[11] => 8

[12] => A

)

$array = array('A','2','3','4','5','6','7','8','9','10','J ','Q','K');

shuffle($array); //Randomly sort array

print_r($array); //Output array

The running results are as follows:
1 2
3
4 5 6 7 8 9 10 11 12 13 14 15 16
Array ( [0] => Q [1] => 3 [2] => 5 [3] => 2 [4] => 10 [5] => 9 [6] => K [7] => 4 [8] => J [9] => 6 [10] => 7 [11] => 8 [12] => A )
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/1016471.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1016471.htmlTechArticleHow to implement random sorting of php arrays. This article describes the implementation method of random sorting of php arrays. Share it with everyone for your reference. The specific implementation method is as follows: 1 2 3 4 5 ?php $array = arra...
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