Home / PHP Tips Generated By ChatGPT / Getting Random Elements from an Array in PHP Fetch a random element from an array with array_rand(). Source Code $input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $randKey = array_rand($input); echo $input[$randKey];