Home >Backend Development >PHP Tutorial >Display one randomly in the array?
<code> $arry = array('A','B','C','D'); $result = array_rand($arry,2); foreach ($result as $val) { echo $arry["$val"].""; } </code>
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