Re: Random number generator

From: Date: Thu, 06 Nov 2008 16:30:01 +0000
Subject: Re: Random number generator
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-283004@lists.php.net to get a copy of this message
That is strange. I get pretty balanced results on this computer. <?php $histogram = array_fill(1, 10, 0); $iterations = 200000; for ($i = 0; $i < $iterations; ++$i) { ++$histogram[round(rand(1, 10))]; } print_r($histogram); ?> Andrew
Simple code, <?php $number = rand(1, 10); include("footer$number.html"); ?> You can see it in action here at the bottom of the page there is a footer. Each footer is the same right now except I have numbered them for testing. As I refresh the page, I get footer10 almost always with an occasional 2 or 4 here and there... http://www.weisd.com/store2/WINHD-9022.php

« previous php.general (#283004) next »