note 110461 added to function.array-rand
| From: | louardi dot abdeltif at yahoo dot fr | Date: | Wed, 24 Oct 2012 14:09:48 +0000 |
| Subject: | note 110461 added to function.array-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191523@lists.php.net to get a copy of this message | ||
Function to return random number of array
function array_random($min, $max, $step = 1) {
$range = range($min, $max, $step);
shuffle($range);
return current($range);
}
Example
echo array_random(100, 200, 5); // 105
echo array_random(100, 200, 5); // 125
echo array_random(100, 200, 5); // 180
----
Server IP: 69.147.83.199
Probable Submitter: 41.251.255.115
----
Manual Page -- http://www.php.net/manual/en/function.array-rand.php
Edit -- https://master.php.net/note/edit/110461
Del: integrated -- https://master.php.net/note/delete/110461/integrated
Del: useless -- https://master.php.net/note/delete/110461/useless
Del: bad code -- https://master.php.net/note/delete/110461/bad+code
Del: spam -- https://master.php.net/note/delete/110461/spam
Del: non-english -- https://master.php.net/note/delete/110461/non-english
Del: in docs -- https://master.php.net/note/delete/110461/in+docs
Del: other reasons-- https://master.php.net/note/delete/110461
Reject -- https://master.php.net/note/reject/110461
Search -- https://master.php.net/manage/user-notes.php