1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - 网站技术 - php - 正文

君子好学,自强不息!

实例说明:

<!DOCTYPE html>
<html>
<body>
<?php
$my_array = array("red","green","blue","yellow","purple");
shuffle($my_array);
print_r($my_array);
?>
<p>Refresh the page to see how shuffle() randomizes the order of the elements in the array.</p>
</body>
</html>

标签含义:

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

该函数为数组中的元素分配新的键名,已存在的键名将被删除(参见下面的实例 1)。

源代码运行结果如下:

image.png

实例1

<!DOCTYPE html>
<html>
<body>

<?php
$my_array = array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow","e"=>"purple");

shuffle($my_array);
print_r($my_array);
?>

<p>Refresh the page to see how shuffle() randomizes the order of the elements in the array.</p>

</body>
</html>

实例1源代码运行结果如下:

image.png



本文来源:1818IP

本文地址:https://www.1818ip.com/post/2505.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。