Page 1 of 1

php(random chosen)

Posted: Tue Jan 09, 2007 4:01 am
by wonderaz
Hello

I have an PHP exercise question like below:


Write a XHTML document to that includes an anchor tag that calls a PHP document. Also write the called PHP document, which returns a randomly chosen greeting from a list of five different greetings. The greetings must be
stored as constant strings in the script. A random number between 0 and 4 can be computed with these lines:

#set the seed for mtrand with the number of microseconds
#since the last full second of the clock
mt_srand ((double) microtime() * 1000000);
$number = mtrand(0, 4 ); #computes a random integer 0-4

Can anyone give me some guidelines in solving this question.
I din't ask for full coding.
I want to try first, so i really need your ideas insolving this question.
Thanks

Posted: Tue Jan 09, 2007 8:15 am
by feyd
It would appear your exercise is from a pretty old reference set. mt_srand() has no longer been needed to be called since PHP 4.2.

As for the meat of your question: An array is the likely intended storage.