php数组函数--从数组中随机选择一个或多个元素

58 阅读1分钟

<?php
$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
print_r(array_rand($a,1));
?>

结果:

b