Display one randomly in the array?

WBOY
Release: 2016-10-09 08:32:29
Original
1274 people have browsed it
<code> $arry = array('A','B','C','D');
$result = array_rand($arry,2);
foreach ($result as $val) 
{
echo $arry["$val"].""; 
}
</code>
Copy after login

Excuse me, this will randomly generate 2 sets of ABCD combinations, such as BC DC AB, etc.
But what I want to display is to display only one. Randomly display A or B or C or D from the array.
How to do this?
After I changed 2 to 1, it failed

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!