Re: a quick question..

From: Date: Sun, 27 Jan 2002 19:21:25 +0000
Subject: Re: a quick question..
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-82304@lists.php.net to get a copy of this message
Or, if you've already set your massive list of variables...: $varname = "nr".rand(0, $n); print ${$varname}; ----- Original Message ----- From: "Miles Thompson" <milesthompson@ns.sympatico.ca> To: "Tauntz" <tauntz@hot.ee>; <php-general@lists.php.net> 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 ? > > > > tauntz@hot.ee > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#82304) next »