Topic: Random Generator

In my quest to learn PHP, I have came across something I could find rather useful! Basically I could do with finding out how (in php) I could create a 'program' where you put in a load of values and then press a button and it will pick one of those values and display it.

Or the reason I want it is I want a 'program' which would pick onen differet football team (from a list) and display it on the screen, each time I pressed a button.

Do you get me? Look forward to your response!

Re: Random Generator

I'm not sure if you wanted a PHP solution or a Ruby solution. Here it is in both:

arr = [1, 2, 3]
arr[rand(arr.size)] # Returns a random element from the array

$arr = array(1, 2, 3);
$arr[array_rand($arr)]; // Returns a random element from the array

By the way, this is a Ruby on Rails forum, so if the question is PHP specific, you may get better response posting on a PHP forum.

Railscasts - Free Ruby on Rails Screencasts

Re: Random Generator

Thanks, i'll try that! (P.S - I posted it on a few forums! Wide range of answers!) cheers