note 63238 added to function.array-rand

From: Date: Thu, 16 Mar 2006 21:23:21 +0000
Subject: note 63238 added to function.array-rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-105945@lists.php.net to get a copy of this message
Modify of last note: <?php if (!function_exists('array_rand')) { function array_rand($array, $lim=1) { mt_srand((double) microtime() * 1000000); for($a=0; $a<=$lim; $a++){ $num[] = mt_srand(0, count($array)-1); } return @$num; } } ?> mt_rand generates a better random number, and with the limit. ---- Server IP: 216.194.113.175 Probable Submitter: 68.227.126.7 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.array-rand.php Edit -- http://master.php.net/note/edit/63238 Del: integrated -- http://master.php.net/note/delete/63238/integrated Del: useless -- http://master.php.net/note/delete/63238/useless Del: bad code -- http://master.php.net/note/delete/63238/bad+code Del: spam -- http://master.php.net/note/delete/63238/spam Del: non-english -- http://master.php.net/note/delete/63238/non-english Del: in docs -- http://master.php.net/note/delete/63238/in+docs Del: other reasons-- http://master.php.net/note/delete/63238 Reject -- http://master.php.net/note/reject/63238 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105945) next »