執行 ❯
獲取您
自己的 PHP
伺服器
×
更改方向
更改主題,深色/淺色
前往 Spaces
<!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>
陣列 ( [0] => 紅色 [1] => 黃色 [2] => 綠色 [3] => 紫色 [4] => 藍色 )
重新整理頁面,看看 shuffle() 如何隨機排列陣列中的元素順序。