1<?php
2//array_rand ( array $array [, int $num = 1 ] )
3$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
4$rand_keys = array_rand($input, 2);
5echo $input[$rand_keys[0]] . "\n";
6echo $input[$rand_keys[1]] . "\n";
7?>
8
9
1<?php
2// array_rand() + shuffle
3$answers = Array('Hello!','Salut!','Vivat!','Chao!','Привет');
4shuffle($answers);
5echo $answers[array_rand($answers)];
6
7// I use it for BotMan:
8$botman->hears('Hi', function ($bot) {
9 $answers = Array('Hello!','Salut!','Vivat!','Chao!','Привет');
10 shuffle($answers);
11 $bot->reply($answers[array_rand($answers)]);
12});