Without long preliminary explanations, I am posting the working code here.
<?php $input = array("test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"); $rand_keys = array_rand($input, 5); echo $input[$rand_keys[0]] . ", "; echo $input[$rand_keys[1]] . ", "; echo $input[$rand_keys[2]] . ", "; echo $input[$rand_keys[3]] . ", "; echo $input[$rand_keys[4]] . " "; ?>