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
Umm I must notify you, just in case you don't know this, that you have to be aware of the fact that the humanity haven't found a way to get a random number (yet. they are working on it while I'm writing this..) (; On Wed, Nov 5, 2008 at 9:43 PM, Gary M. Josack <[EMAIL PROTECTED]> wrote: > WEI

Re: [PHP] Random number generator

2008-11-05 Thread Gary M. Josack
WEISD wrote: Just starting out, thanks. So, I should have prefaced the question with, New to PHP... ""TG"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Here's how you generate a random number: http://us.php.net/manual/en/function.rand.php There are a number of things

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
Just starting out, thanks. So, I should have prefaced the question with, New to PHP... ""TG"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Here's how you generate a random number: http://us.php.net/manual/en/function.rand.php There are a number of things you can do wit

Re: [PHP] Random number generator

2008-11-05 Thread TG
Here's how you generate a random number: http://us.php.net/manual/en/function.rand.php 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

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