Or, if you've already set your massive list of variables...: $varname = "nr".rand(0, $n); print ${$varname};
----- Original Message ----- From: "Miles Thompson" <[EMAIL PROTECTED]> To: "Tauntz" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Sunday, January 27, 2002 8:15 PM Subject: Re: [PHP] a quick question.. > Try this: > > Store variables in an array, say $msg_array. (For those of Hungarian preference, $arrMessages.) > $index = rand (0, $n) > echo $msg_array[ $index ] > > Now this will require a bit of messing about, seeding the randomizer, etc., but you get the idea. > > Miles Thompson > > > On Sunday 27 January 2002 03:00 pm, Tauntz wrote: > > If I have n variables: > > $nr1 = "some text"; > > $nr2 = "some other text" > > $nr3.... > > .... > > and I want to print the text "randomly" (like if I enter the page.. it > > displays $nr1... next time it displays $nr 5.. etc) how can I achieve it ? > > > > [EMAIL PROTECTED] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]