note 27339 added to function.rand

From: Date: Mon, 02 Dec 2002 19:00:35 +0000
Subject: note 27339 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-40257@lists.php.net to get a copy of this message
A way to quicky and randomly select a value from an array can be done a follows. <?php #Create the array $array = array('Dave','Mary','Arnold','Doug'); #Create a random number $num = rand(0,3); #Output print ("<title>".$array[$num]."</title>"); ?> -- http://www.php.net/manual/en/function.rand.php http://master.php.net/manage/user-notes.php?action=edit+27339 http://master.php.net/manage/user-notes.php?action=delete+27339 http://master.php.net/manage/user-notes.php?action=reject+27339

« previous php.notes (#40257) next »