第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

兩鏈接隨機php

兩鏈接隨機php

PHP
慕桂英3389331 2021-04-28 13:24:51
我有n個鏈接,每個鏈接都有自己的關(guān)鍵字。我想一次在php中顯示兩個鏈接。有什么建議嗎?這是輸入示例:$text[1] = "<a href=https://www.website.ext/post-1/>words 1</a>";$text[2] = "<a href=https://www.website.ext/post-2/>words 2</a>";$text[3] = "<a href=https://www.website.ext/post-3/>words 3</a>";$text[4] = "<a href=https://www.website.ext/post-4/>words 4</a>";$text[5] = "<a href=https://www.website.ext/post-5/>words 5</a>"....輸出示例:words 1words 3orwords 5words 2orwords 4words 1
查看完整描述

2 回答

?
翻翻過去那場雪

TA貢獻2065條經(jīng)驗 獲得超14個贊

這是可以完成任務的代碼示例。您可以使用mt_rand()函數(shù)從數(shù)組中選擇一個隨機索引,然后對其進行回顯,也可以使用array_rand()函數(shù)從數(shù)組中隨機抽取給定數(shù)量的元素。

<?php

#example 1

$text = array("a", "b", "c", "d", "e");


$keys = array_rand($text, 2);


echo $text[$keys[0]] . "\n";

echo $text[$keys[1]] . "\n";


#example 2


$text = array("a", "b", "c", "d", "e");


echo $text[mt_rand(0,4)] . "\n";

echo $text[mt_rand(0,4)] . "\n";


?>


查看完整回答
反對 回復 2021-05-21
  • 2 回答
  • 0 關(guān)注
  • 304 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號