note 83360 deleted from function.mt-rand by googleguy

From: Date: Tue, 22 Oct 2013 11:00:25 +0000
Subject: note 83360 deleted from function.mt-rand by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197005@lists.php.net to get a copy of this message
Note Submitter: don_knotts at hotmail dot com ---- I forgot to add a side-note to my post about the unique random number function. If the array count is more than half of the random number max, the function could take a very long time to process, maybe even go into an infinite loop. The best way to avoid this is to set the max at twice the array count; i.e. if you want an array of 10 unique random numbers, the maximum random number needs to be at least 20. For my purposes, I have 50 pictures to choose from, and the function randomly picks 20 of them to display on the webpage, without displaying an image twice.

« previous php.notes (#197005) next »