063 - Array Rand
0
red


063-a - Array Rand with paramters as a Number
red
yellow

063-b - Array Rand with Associative Array
Array
(
    [0] => b
    [1] => d
)

063-c - Shuffle Array
Array
(
    [0] => yellow
    [1] => blue
    [2] => green
    [3] => brown
    [4] => red
)

063-d - Shuffle With Associative Array
Array
(
    [0] => red
    [1] => green
    [2] => blue
    [3] => yellow
)
<?php // 063 - Array Rand echo "</br><span class='myheading'>063 - Array Rand</span></br>"; $color = array("red","green","blue","yellow","brown"); $newArray = array_rand($color); echo "<pre>"; print_r($newArray); echo "</pre>"; echo $color[$newArray]."<br><br>"; // 063-a - Array Rand with paramters as a Number echo "</br><span class='myheading'>063-a - Array Rand with paramters as a Number</span></br>"; $newArray1 = array_rand($color, 2); echo $color[$newArray1[0]]."<br>"; echo $color[$newArray1[1]]."<br>"; // 063-b - Array Rand with Associative Array echo "</br><span class='myheading'>063-b - Array Rand with Associative Array</span></br>"; $color1 = array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow"); $newArray2 = array_rand($color1, 2); echo "<pre>"; print_r($newArray2); echo "</pre>"; // 063-c - Shuffle Array echo "</br><span class='myheading'>063-c - Shuffle Array</span></br>"; $color2 = array("red","green","blue","yellow","brown"); shuffle($color2); echo "<pre>"; print_r($color2); echo "</pre>"; // 063-d - Shuffle With Associative Array echo "</br><span class='myheading'>063-d - Shuffle With Associative Array</span></br>"; $color3 = array("a"=>"red","b"=>"green","c"=>"blue","d"=>"yellow"); shuffle($color3); echo "<pre>"; print_r($color3); echo "</pre>"; ?>