-4
$first = "Text 1"  
$second = "Text 2"  
$third = "Text 3"  
$fourth = "Text 4"  
$fifth = "Text 5"  

我想创建一个函数,它显示 $second 和 $fourth 的频率是其他变量的 3 倍。

这个怎么做?

4

1 回答 1

2
$arr = array($first, $second, $second, $second, $third, $fourth, $fourth, $fourth, $fifth);
$elem = $arr[array_rand($arr)];

这将从数字变为变量的值

于 2012-11-26T20:22:05.967 回答