登录注册

18250178511

PHP shuffle() 函数 打乱数组顺序

作者:admin      时间:2016-01-04 09:09:09

定义和用法

shuffle() 函数把数组中的元素按随机顺序重新排列。

若成功,则返回 TRUE,否则返回 FALSE。

注释:本函数为数组中的单元赋予新的键名。这将删除原有的键名而不仅是重新排序。

注释:自 PHP 4.2.0 起,不再需要用 srand() 或 mt_srand() 函数给随机数发生器播种,现已被自动完成。

语法

shuffle(array)
参数 描述
array 必需。规定要使用的数组。

例子

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

输出:

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


发表评论

评论列表

匿名

It's a real plesruae to find someone who can think like that http://aetnkdl.com [url=http://djxiffzs.com]djxiffzs[/url] [link=http://pqrilyou.com]pqrilyou[/link]

2016-05-31 23:38:24

匿名

<a href="http://vtpcjzhj.com">Arciltes</a> like this just make me want to visit your website even more.

2016-05-31 17:02:52

匿名

Articles like these put the consumer in the driver seat-very imapotrnt. http://yjudwzr.com [url=http://kunqkfsyex.com]kunqkfsyex[/url] [link=http://bqrwcdcr.com]bqrwcdcr[/link]

2016-05-30 17:58:21

匿名

That's a slick answer to a <a href="http://poagdt.com">chnalengilg</a> question

2016-05-29 22:02:11

匿名

Reading this makes my deniisocs easier than taking candy from a baby.

2016-05-29 13:02:06