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

Re: [PHP] Random number generation and phpBB search IDs

2004-11-27 Thread Gordon Mckeown
Many thanks Thomas and Maciek. I'll try removing mt_srand to start with, and if that doesn't work out I'll put in the uniqueness check. Cheers, Gordon. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Random number generation and phpBB search IDs

2004-11-27 Thread Thomas S. Crum - AAA Web Solution, Inc.
keown [mailto:[EMAIL PROTECTED] Sent: Saturday, November 27, 2004 11:44 AM To: [EMAIL PROTECTED] Subject: [PHP] Random number generation and phpBB search IDs Hi, I'm currently experiencing a problem with a phpBB board that appears to be due to the way random number generation works in PHP. I ha

Re: [PHP] Random number generation and phpBB search IDs

2004-11-27 Thread M. Sokolewicz
Gordon McKeown wrote: Apologies, my mail client was supposed to line-wrap that for me - Hi, I'm currently experiencing a problem with a phpBB board that appears to be due to the way random number generation works in PHP. I have posted on serveral phpBB boards and have received no answers, s

Re: [PHP] Random number generation and phpBB search IDs

2004-11-27 Thread Gordon Mckeown
Apologies, my mail client was supposed to line-wrap that for me - Hi, I'm currently experiencing a problem with a phpBB board that appears to be due to the way random number generation works in PHP. I have posted on serveral phpBB boards and have received no answers, so I think I need to un

[PHP] Random number generation and phpBB search IDs

2004-11-27 Thread Gordon Mckeown
Hi, I'm currently experiencing a problem with a phpBB board that appears to be due to the way random number generation works in PHP. I have posted on serveral phpBB boards and have received no answers, so I think I need to understand how PHP is dealing with this in order to resolve it. phpBB ge

[PHP] Random Number Generation

2003-03-20 Thread Christopher J. Crane
I have a script that loads 13 or more file names into an array. Then at random I select one of the names out of the array. This files are background songs used on my webpage. Streaming a different song each time the page is refreshed or loaded. My issue is I do not want the same song to ever be pla

Re: [PHP] Random Number Genertation

2002-12-18 Thread Somesh
Hi shaun, Store all those numbers in an array and use the function array_rand. On Wed, 18 Dec 2002, shaun wrote: > Hi, > > Say i have a set of non sequential numbers for example: 1 3 8 12 13 16 19 > 21. > > How can i get php to take a random number from this set? > > Thanks f

Re: [PHP] Random Number Genertation

2002-12-18 Thread Wico de Leeuw
http://www.php.net/manual/en/function.array-rand.php At 11:35 18-12-02 +, shaun wrote: Hi, Say i have a set of non sequential numbers for example: 1 3 8 12 13 16 19 21. How can i get php to take a random number from this set? Thanks for your help -- PHP General Mailing List (http://www.

[PHP] Random Number Genertation

2002-12-18 Thread shaun
Hi, Say i have a set of non sequential numbers for example: 1 3 8 12 13 16 19 21. How can i get php to take a random number from this set? Thanks for your help -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Random number Question

2002-04-02 Thread Hiroshi Ayukawa
$guess = = $number is wrong. You should write: $guess == $number Regards, Hiroshi Ayukawa http://hoover.ktplan.ne.jp/kaihatsu/php_en/index.php?type=top -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Random number Question

2002-03-12 Thread Jason Wong
On Saturday 13 March 2010 11:54, Jennifer Downey wrote: > Hi all, > > I having a hard time understanding why this won't work. I have a form which > is suppose to pass the guess to the script. Here it is: It's no good just telling us it doesn't work. You need to tell us what happens when you run

RE: [PHP] Random number Question

2002-03-12 Thread Balaji Ankem
Try Now: The computer has picked a number between 1 and 10. Guess the number and you win! Enter your guess: -Original Message- From: Jennifer Downey [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 13, 2010 9:25 AM To: [EMAIL PROTECTED] Subject: [PHP] Random number Question Hi

[PHP] Random number Question

2002-03-12 Thread Jennifer Downey
Hi all, I having a hard time understanding why this won't work. I have a form which is suppose to pass the guess to the script. Here it is: the form is guess.php: The computer has picked a number between 1 and 10. Guess the number and you win! Enter your guess: The script is number.php:

Re: [PHP] Random number

2001-08-30 Thread Augusto Cesar Castoldi
Use this function, the "$num" argument, is the total of numbers. Ex: if $num is 5, the funtion will return "56743", is five numbers. function random($num) { srand ((double) microtime() * 100); $temp = rand().rand().rand(); $temp = substr($temp, 0, $num); return $temp; } //fim functio

[PHP] Random number

2001-08-30 Thread Rosen
Hi, I'm using PHP code from manual: srand( (double) microtime() * 100); // Get random User ID $uid=rand(); but it dowsn't work ! Thanks, Rosen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTE

[PHP] random number problem...

2001-07-10 Thread James Bartlett
Hi, I've written a picture rotation script, file paths are stored in a file and are called depending on a random number generator.. The problem is that out of 14 possible numbers only 7 are been generated. the code I'm using is... srand ( (double) microtime()*1000); $numbertodisplay = r

Re: [PHP] Random number

2001-05-18 Thread Tolga \"thorr\" Orhon
If you need just plain random number generator check manual. If you want a true pseudo-random number generator you may want to check: http://www.ulib.org/webRoot/Books/Numerical_Recipes/bookcpdf.html Those generators used in scientific calculations where true reproducible and low correlated rando

RE: [PHP] Random number

2001-05-18 Thread scott [gts]
i love when newbies ask for help and i'm able to help, but when it comes to people being just plain lazy, i agree with Miles... ** please read the docs before asking questions ** > -Original Message- > From: Miles Thompson [mailto:[EMAIL PROTECTED]] > Subject: Re: [PHP]

Re: [PHP] Random number

2001-05-18 Thread Miles Thompson
Come on - you haven't even bothered to check the manual. Search for this at php.net Miles At 03:09 PM 5/18/01 -0400, Daniel Coronel wrote: >Hi! >I need to really generate a random number in a function but not like doing >it. >Somebody could help me. Thanks. > >Daniel Coronel. -- PHP General

[PHP] Random number

2001-05-18 Thread Daniel Coronel
Hi! I need to really generate a random number in a function but not like doing it. Somebody could help me. Thanks. Daniel Coronel.

Re: [PHP] Random number generation...

2001-05-02 Thread Phillip Bow
3B733@BOOTROS... > The manual also says: > mt_rand -- Generate a better random value > > I've been using mt_rand() over rand() every time - is there any reason not > to? > > Cheers > Jon > > > -Original Message- > From: elias [mailto:[EMAIL PROTECTED

RE: [PHP] Random number generation...

2001-05-02 Thread Jon Haworth
The manual also says: mt_rand -- Generate a better random value I've been using mt_rand() over rand() every time - is there any reason not to? Cheers Jon -Original Message- From: elias [mailto:[EMAIL PROTECTED]] Sent: 03 May 2001 00:05 To: [EMAIL PROTECTED] Subject: Re: [PHP] R

Re: [PHP] Random number generation...

2001-05-02 Thread Avetis Avagyan
Regards, Avetis [EMAIL PROTECTED] wrote: > Hi there, > A potentially dumb question here. > > Is there an easy way to display a random number between 1 and 20? > > I have looked on line, but either I am looking inall teh wrong places, or there > isn't this script on-line. > > Can anyone point m

RE: [PHP] Random number generation...

2001-05-02 Thread Jon Haworth
Wotcha Tris :-) Try this: mt_srand((double)microtime()*100); $my_random_number = mt_rand(1, 20); HTH Jon -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: 02 May 2001 12:07 To: [EMAIL PROTECTED] Subject: [PHP] Random number generation... Hi there, A

Re: [PHP] Random number generation...

2001-05-02 Thread elias
why not use the rand() ? manual says: rand -- Generate a random value Description int rand ([int min [, int max]]) If called without the optional min, max arguments rand() returns a pseudo-random value between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for examp

[PHP] Random number generation...

2001-05-02 Thread Tristan . Pretty
Hi there, A potentially dumb question here. Is there an easy way to display a random number between 1 and 20? I have looked on line, but either I am looking inall teh wrong places, or there isn't this script on-line. Can anyone point me in the right direction? Cheers, Tris... ***