How to get random element of array in PHP

Snippet

Returns a random element of a given array:

downloadcopy
<?php 
// your array
$words = array('wtools', 'web', 'tools', 'sandbox'); 
echo $words[mt_rand(0, count($words)-1)];