如何从php字符串随机2个值


How to random 2 value from php string?

如何从php字符串随机2个值?

<?PHP
    $xxx = (aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj)
?>

如何从$xxx随机2个值并添加2个值(唯一)到php变量?

$one = "ccc"; ADN $two = "ggg";

使用array_rand() php函数

$result = array_rand($array, 2);

它将返回2个值作为$array[$result[0]] and $array[$result[1]],如果字符串以逗号(,)分隔那么可以用逗号将字符串分隔成数组格式