note 103115 added to function.rand

From: Date: Sat, 26 Mar 2011 12:25:38 +0000
Subject: note 103115 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-178235@lists.php.net to get a copy of this message
<? $b=array(); for($y=0;$y<10000;$y++){$b[rand(0,5)]++;} $r="Rand: "; for($y=0;$y<count($b);$y++){$r.=$y.":".$b[$y]."; ";} echo $r; ?> Rand: 0:330; 1:2021; 2:1899; 3:1878; 4:1971; 5:1901; Rand: 0:284; 1:1947; 2:1970; 3:1861; 4:2044; 5:1894; Rand: 0:276; 1:1917; 2:1989; 3:1979; 4:1921; 5:1918; Rand: 0:278; 1:1957; 2:1898; 3:1999; 4:1895; 5:1973; Rand: 0:262; 1:1923; 2:1988; 3:1933; 4:1959; 5:1935; Rand: 0:277; 1:1937; 2:1923; 3:1945; 4:1982; 5:1936; And this is supposed to be random? Key 0 is used quite fewer than the other number, which are higher than zero!? martin www.mshd.net ---- Server IP: 208.69.120.55 Probable Submitter: 96.240.205.165 ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- https://master.php.net/note/edit/103115 Del: integrated -- https://master.php.net/note/delete/103115/integrated Del: useless -- https://master.php.net/note/delete/103115/useless Del: bad code -- https://master.php.net/note/delete/103115/bad+code Del: spam -- https://master.php.net/note/delete/103115/spam Del: non-english -- https://master.php.net/note/delete/103115/non-english Del: in docs -- https://master.php.net/note/delete/103115/in+docs Del: other reasons-- https://master.php.net/note/delete/103115 Reject -- https://master.php.net/note/reject/103115 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178235) next »