Home > Backend Development > PHP Tutorial > Several ways to randomly sort php arrays_PHP tutorial

Several ways to randomly sort php arrays_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:50:01
Original
1035 people have browsed it

In PHP, if we want to randomly sort the array, we only need to use the shuffle function, but shuffle can only use one-dimensional arrays. Below, I will introduce you to several array sorting methods.


You can use the shuffle function in PHP to implement random sorting of arrays.

The code is as follows
 代码如下 复制代码

$test=array();
$test[]=array(
'title'=>'Q1.较为科学的安全期算法是什么?',
        );
$test[]=array(
        'title'=>'Q2.较为科学的安全期算法是什么?',
        );
$test[]=array(
        'title'=>'Q3.较为科学的安全期算法是什么?',
        );
$test[]=array(
        'title'=>'Q4.较为科学的安全期算法是什么?',
        );
//随机排序
shuffle($test);
print_r($test);
?>

Copy code
$test=array();

$test[]=array(

'title'=>'Q1. What is the more scientific safe period algorithm? ', $test[]=array( 'title'=>'Q2. What is the more scientific safe period algorithm? ', ); $test[]=array( 'title'=>'Q3. What is the more scientific safe period algorithm? ', ); $test[]=array( 'title'=>'Q4. What is the more scientific safe period algorithm? ', ); //Randomly sort shuffle($test); print_r($test); ?>
http://www.bkjia.com/PHPjc/632669.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632669.htmlTechArticleIn php, if we want to randomly sort the array, we only need to use the shuffle function, but shuffle can only use one Dimensional array, let me introduce to you several array sorting methods. ...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template