note 103872 deleted from function.array-rand by danbrown

From: Date: Mon, 09 May 2011 17:25:12 +0000
Subject: note 103872 deleted from function.array-rand by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179567@lists.php.net to get a copy of this message
Note Submitter: skyler at sixteenink dot com ---- Alternatively, this also works. <?php // Array: $input = array("one", "two", "three", "four", "five"); // Find the number of nodes. Subtract one, to account for the first node being 0. $maximum = count($input) -1; // Get the random number used to output a random node $randomArray = rand(0, $maximum); // Results echo $input[$randomArray]; ?>

« previous php.notes (#179567) next »