1<?php
2$indexedArray = array("red", "blue", "green", "black");
3echo $indexedArray[array_rand($indexedArray)];
4?>
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$colors=["red","blue","green","orange"];
2echo $colors[array_rand($colors)];//green (or any color randomly)
1$array = ["a", "b", "c"];
2$random = $array[ Rand(0, count($array)-1) ];
3
4echo $random; // a or b or c
1<?php
2$indexedArray = array("red", "blue", "green", "black");
3
4echo $indexedArray[0] . "<br>";
5echo $indexedArray[1] . "<br><br>";
6
7$array_random = array_rand($indexedArray, 2);
8
9echo $indexedArray[$array_random[0]] . "<br>";
10echo $indexedArray[$array_random[1]] . "<br>";
11?>