$items = Array(523,3452,334,31,...5346);
Run Code Online (Sandbox Code Playgroud)
该数组的每个项目都是一些数字.
我如何从中获取随机物品$items
?
Vin*_*ard 451
echo $items[array_rand($items)];
Run Code Online (Sandbox Code Playgroud)
pas*_*ets 33
如果您不介意在其他时间再次选择相同的项目:
$items[rand(0, count($items) - 1)];
小智 16
<?php
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2);
echo $input[$rand_keys[0]] . "\n";
echo $input[$rand_keys[1]] . "\n";
?>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
240865 次 |
最近记录: |