Possible Duplicate:
Get random item from array
I need a code to set a random string for a variable.
of course I have the string and they are not generated.
I can put the strings in the array
$strings= array('one', 'two', 'yes', 'no', 'yeaa');
$random_str = ????
I need $random_str to be one or no or maybe two.
Totally randomly from $strings.
rand and shuffle function didn’t do that for me simply, and I’m beginner in php, so I need your help.
so thank you guys for helping me
You can use
array_randto get a random element from an array: