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 that

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, including

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 a particular file in an

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. ?php include('GeneratedNumber.html'); ? Is there an

RE: [PHP] Random number generator

2008-11-06 Thread Jay Blanchard
[snip] ?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

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. ?php $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 Micah Gersten
WEISD wrote: That is strange. I get pretty balanced results on this computer. ?php $histogram = array_fill(1, 10, 0); $iterations = 20; for ($i = 0; $i $iterations; ++$i) { ++$histogram[round(rand(1, 10))]; } print_r($histogram); ? Andrew Simple code, ?php $number =

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

Re: [PHP] Random number generator

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

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

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 it will do. I

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...

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 Micah Gersten
Stephen wrote: On Thu, 11/6/08, WEISD [EMAIL PROTECTED] wrote: That is strange. I get pretty balanced results on this computer. ?php $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 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 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

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. ?php include('GeneratedNumber.html'); ? Is there an easy way to do this? Get the time and use the last digit converting 0 to 10.

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 WEISD
Just starting out, thanks. So, ?php $number = rand(1, 10); include('$number.html'); ? 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:

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. ?php include('GeneratedNumber.html'); ? Is there an easy way to do this? Get the time and use the last digit converting 0

Re: [PHP] Random number generator

2008-11-05 Thread Gary M. Josack
WEISD wrote: Just starting out, thanks. So, ?php $number = rand(1, 10); include('$number.html'); ? 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:

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: WEISD

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. ?php include('GeneratedNumber.html'); ? Is there an easy way to do this? Thanks

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

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,

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

2004-11-27 Thread Thomas S. Crum - AAA Web Solution, Inc.
Use a database query to verify the random number has not been used before. $number_checker = 1; while ($number_checker != 0){ #insert your $random_number code $query = SELECT COUNT(*) AS total FROM some_table WHERE random_number_field = '$random_number'; $result =

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 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

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 for

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 Balaji Ankem
Try Now: form action=number.php method=post The computer has picked a number between 1 and 10. Guess the number and you win!BR Enter your guess: input type=text name=guess value= size=3 INPUT TYPE=submit VALUE=Submit my number NAME=submit /form -Original Message- From: Jennifer Downey

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 it.

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 function

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

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] Random number

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

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

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 Avetis Avagyan
?php srand((double)microtime()*100); $number = rand(1,20); echo $number; ? 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

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] Random

Re: [PHP] Random number generation...

2001-05-02 Thread Phillip Bow
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] Random number ge