我一直在寻找一点点,但我找不到任何值得的东西。所以这是我的问题:
我有一个很长的字符串,我想从中挑选 3 个随机集合,然后用逗号分隔 3 个字符串。以下是相关代码:
$mapsandmodes = array("Raid - Hardpoint", "Raid - Capture The Flag", "Raid - Search and Destroy", "Plaza - Hardpoint", "Plaza - Capture The Flag", "Aftermath - Search and Destroy", "Express - Capture The Flag", "Express - Hardpoint", "Express - Search and Destroy", "Meltdown - Search and Destroy", "Slums - Search and Destroy", "Slums - Hardpoint", "Slums - Capture The Flag", "Standoff - Capture The Flag", "Standoff - Search and Destroy", "Yemen - Hardpoint");
我尝试使用$mapswithmodes = array_rand($mapsandmodes)
,但输出一个数字(到目前为止我已经得到“1”和“2”)。我希望它为该长行选择 3 个随机字符串集,然后用逗号分隔 3 个字符串,以便将其放入 MYSQL 表中。