PHP: get random array value


Warning: Undefined array key "socialize_RedditWidget" in /home/phpacd/websites/shkodenko.com/wp-content/plugins/socialize/frontend/socialize-services.php on line 166

Sometimes it can be useful to get random array value in PHP.
You can use my function below to do it:

function getRandomArrayValue($a) {
	$k = array_rand($a);
	$v = $a[$k];
	return $v;
}

If you have any ideas how to make it better: all your comments are welcomed.

Posted in PHP