<BR><?php <BR>class getValues { <BR>public function inputValue($inputArray) { <BR>$this->inputArray = $inputArray; <BR>} <BR>public function getValue($number) { <BR>$this->number = $number; <BR>for($i = 0; $i number; $i ++) { <BR>$index = rand ( 0, count ( $this->inputArray ) - 1 - $i ); <BR>$getArray [$i] = $this->inputArray [$index]; <BR>unset ( $this->inputArray [$index] ); <BR>for($k = $index; $k inputArray ) - 1; $k ++) { <BR>$this->inputArray [$k] = $this->inputArray [$k + 1]; <BR>} <BR>} <BR>//asort ( $getArray ); // 从小到大排序,根据需要修改 <BR>return $getArray; <BR>} <BR>} <br><br>//测试代码 <BR>$keywords = array( <BR>"我们", <BR>"你们", <BR>"他们" <BR>); <BR>$getValue=new getValues(); <BR>$getValue->inputValu<strong>+本文来源gao@daima#com搞(%代@#码网</strong><pre>搞代gaodaima码
e($keywords);
$key = $getValue->getValue(1);//从数组中随机抽取一个元素
echo $key;
?>