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

Several ways to randomly sort php arrays_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:50:011029browse

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:
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