Re: [PHP] Random number generator

2008-11-06 Thread tedd
At 11:35 AM -0600 11/6/08, WEISD wrote: http://www.weisd.com/store2/WINHD-9022.php Not me -- I get a normal distribution. Cheers, tedd Thanks Tedd, That is because it is using time now and not rand... Just as point of notice. When I ask a question and provide a url, I keep the url t

Re: [PHP] Random number generator

2008-11-06 Thread WEISD
1. change the number to a string: $t = (string) time(); 2. chop off the last char of the string: $char = substr($t, -1); 3. you're done...: include "footer$char.html"; Time wins certainly produces better results, at least for what I am doing, than rand... Thanks all for your input...

Re: [PHP] Random number generator

2008-11-06 Thread Micah Gersten
Stephen wrote: > On Thu, 11/6/08, WEISD <[EMAIL PROTECTED]> wrote: > > >>> That is strange. I get pretty balanced results on this >>> >> computer. >> >>> >> >>> $histogram = array_fill(1, 10, 0); >>> >>> $iterations = 20; >>> >>> for ($i = 0; $i < $iterations; ++$i) { >>>++$h

Re: [PHP] Random number generator

2008-11-06 Thread WEISD
http://www.weisd.com/store2/WINHD-9022.php Not me -- I get a normal distribution. Cheers, tedd Thanks Tedd, That is because it is using time now and not rand... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Random number generator

2008-11-06 Thread tedd
At 10:30 AM -0600 11/6/08, WEISD wrote: 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

Re: [PHP] Random number generator

2008-11-06 Thread Jim Lucas
WEISD wrote: > >> >> Computer functions to generate random numbers are not designed to do >> what their name suggests. >> >> Software testing requires repeatability, and this includes random >> number generation. >> >> Without knowing how PHP seeds the generator it is difficult to predict >> what

Re: [PHP] Random number generator

2008-11-06 Thread Maciek Sokolewicz
WEISD wrote: Computer functions to generate random numbers are not designed to do what their name suggests. Software testing requires repeatability, and this includes random number generation. Without knowing how PHP seeds the generator it is difficult to predict what it will do. I st

Re: [PHP] Random number generator

2008-11-06 Thread WEISD
That is strange. I get pretty balanced results on this computer. Andrew Simple code, 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 alwa

Re: [PHP] Random number generator

2008-11-06 Thread WEISD
Computer functions to generate random numbers are not designed to do what their name suggests. Software testing requires repeatability, and this includes random number generation. Without knowing how PHP seeds the generator it is difficult to predict what it will do. I still think taki

Re: [PHP] Random number generator

2008-11-06 Thread Micah Gersten
WEISD wrote: > >> That is strange. I get pretty balanced results on this computer. >> >> > >> $histogram = array_fill(1, 10, 0); >> >> $iterations = 20; >> >> for ($i = 0; $i < $iterations; ++$i) { >>++$histogram[round(rand(1, 10))]; >> } >> >> print_r($histogram); >> >> ?> >> >> Andrew > >

Re: [PHP] Random number generator

2008-11-06 Thread Stephen
On Thu, 11/6/08, WEISD <[EMAIL PROTECTED]> wrote: > > That is strange. I get pretty balanced results on this > computer. > > > > > > > $histogram = array_fill(1, 10, 0); > > > > $iterations = 20; > > > > for ($i = 0; $i < $iterations; ++$i) { > >++$histogram[round(rand(1, 10))]; > > } > >

RE: [PHP] Random number generator

2008-11-06 Thread Jay Blanchard
[snip] 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... [/snip] So there fore it is random, or

Re: [PHP] Random number generator

2008-11-06 Thread WEISD
""Gary M. Josack"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Stephen wrote: On a php web page I want to generate a random number between say 1 and 10 and then use that number to reference a particular file in an include tag. Is there an easy way to do this? Get the tim

Re: [PHP] Random number generator

2008-11-06 Thread Andrew Ballard
On Thu, Nov 6, 2008 at 10:53 AM, WEISD <[EMAIL PROTECTED]> wrote: > > ""Gary M. Josack"" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> Stephen wrote: On a php web page I want to generate a random number between say 1 and 10 and then use that number to reference

Re: [PHP] Random number generator

2008-11-06 Thread Daniel P. Brown
On Thu, Nov 6, 2008 at 3:52 AM, Amisha_Sharma <[EMAIL PROTECTED]> wrote: > > Hi > > you can use PHP rand() function for selecting a random number between 1 to > 100. Amisha, Welcome to the list, but please don't top post. For a list of all the guidelines for the official PHP lists, inclu

Re: [PHP] Random number generator

2008-11-06 Thread Amisha_Sharma
Hi you can use PHP rand() function for selecting a random number between 1 to 100. http://www.senpai-it.com/dedicated_servers.php Senpai IT Solutions Dedicated Server at low cost WEISD wrote: > > > On a php web page I want to generate a random number between say 1 and 10 > and then use t

Re: [PHP] Random number generator

2008-11-05 Thread Ashley Sheridan
On Wed, 2008-11-05 at 12:41 -0600, WEISD wrote: > On a php web page I want to generate a random number between say 1 and 10 > and then use that number to reference a particular file in an include tag. > > > > Is there an easy way to do this? > > Thanks > include "manual.php"; lesson = new

Re: [PHP] Random number generator

2008-11-05 Thread Nitsan Bin-Nun
gt;> There are a number of things you can do with that to select a random file >>> and >>> include it. Have an associative array where the random number matches an >>> array key and the value is the filename you want, is one method. >>> >>> J

Re: [PHP] Random number generator

2008-11-05 Thread Gary M. Josack
--- Original Message - From: "WEISD" <[EMAIL PROTECTED]> To: php-general@lists.php.net Date: Wed, 5 Nov 2008 12:41:21 -0600 Subject: [PHP] Random number generator On a php web page I want to generate a random number between say 1 and 10 and then use that number to referen

Re: [PHP] Random number generator

2008-11-05 Thread Gary M. Josack
Stephen wrote: On a php web page I want to generate a random number between say 1 and 10 and then use that number to reference a particular file in an include tag. Is there an easy way to do this? Get the time and use the last digit converting 0 to 10. Stephen rand(1, 10); -- P

Re: [PHP] Random number generator

2008-11-05 Thread WEISD
age - From: "WEISD" <[EMAIL PROTECTED]> To: php-general@lists.php.net Date: Wed, 5 Nov 2008 12:41:21 -0600 Subject: [PHP] Random number generator On a php web page I want to generate a random number between say 1 and 10 and then use that number to reference a particular fi

Re: [PHP] Random number generator

2008-11-05 Thread TG
s one method. Just starting out with PHP or is this a homework assignment? :) -TG - Original Message - From: "WEISD" <[EMAIL PROTECTED]> To: php-general@lists.php.net Date: Wed, 5 Nov 2008 12:41:21 -0600 Subject: [PHP] Random number generator > > On a php we

Re: [PHP] Random number generator

2008-11-05 Thread Stephen
> On a php web page I want to generate a random number > between say 1 and 10 > and then use that number to reference a particular file in > an include tag. > > > > Is there an easy way to do this? Get the time and use the last digit converting 0 to 10. Stephen -- PHP General Mailing List

[PHP] Random number generator

2008-11-05 Thread WEISD
On a php web page I want to generate a random number between say 1 and 10 and then use that number to reference a particular file in an include tag. Is there an easy way to do this? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub