- array_values: documentation ( source)
- array_rand: documentation ( source)
<?php
$assoc = [
'a' => 'b',
'c' => 'd',
'e' => 'f',
'g' => 'g',
];
$plain = array_values($assoc);
echo $assoc[array_rand($assoc)], "\n";
echo $plain[array_rand($plain)], "\n";