array_PHP チュートリアルからいくつかの要素をランダムに抽出する PHP コード

WBOY
リリース: 2016-07-21 15:14:58
オリジナル
844 人が閲覧しました

コードをコピーします コードは次のとおりです:

class getValues {
public function inputValue($inputArray) {
$this->inputArray = $inputArray
}
public;関数 getValue($number ) {
$this->number = $number
for($i = 0; $i number; $i ++) {
$index = rand ( 0 , count ( $this ->inputArray ) - 1 - $i );
$getArray [$i] = $this->inputArray [$index];
unset ( $this->inputArray [$index] ) ;
for($ k = $index; $k inputArray ) - 1; $k ++) {
$this->inputArray [$k] = $this->inputArray [$k + 1 ];
}
}
//asort ( $getArray ); // 必要に応じて変更します
return $getArray;
$keywords = array(
「私たち」、
「あなた」、
「彼ら」
);
$getValue=new getValues();
$key = $getValue->getValue (1);// 配列
echo $key からランダムに要素を選択します
? >





http://www.bkjia.com/PHPjc/326147.html
www.bkjia.com

tru​​ehttp://www.bkjia.com/PHPjc/326147.html技術記事次のようにコードをコピーします。 ?php class getValues { public function inputValue($inputArray) { $this-inputArray = $inputArray; } public function getValue($number) { $this-number = $nu...
ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!