array_rand

It fetches one or more random entries out of an array

Example

<?php
$array = array(“PHP”, “ASP”, “JSP”);
$keys = array_rand($array, 2);
echo $array[$keys[0]];
?>

Output

PHP

Share