Glacai

msg:440525 | 1:40 pm on Aug 12, 2003 (gmt 0) |
srand is just to seed the generator $rank = rand(4, 10);
|
StopSpam

msg:440526 | 3:31 pm on Aug 12, 2003 (gmt 0) |
Hi Glacai... thanks for your reply and wecome to WebmastersWorld im new to srank in fact whole cgi scripting ect learning sinse few months now ... so i just include this ; $rank = rand(4, 10); or do i need to include a extra line as well to start the random tool? like: srand; my book says you may only include once ... so i add to top of script this?corect me if i am wrong; srand; then $rank = rand(4, 10); thats all right? thx
|
Glacai

msg:440527 | 4:28 pm on Aug 12, 2003 (gmt 0) |
Hi StopSpam, thanks for the welcome but I been around coming up to a year! but all the help I can give is usually already answered. Anyway I don't think you need to use srand in the latest php but if you do yes, you should only seed it once each execution. Sorry forgot, you need to seed with a number, usually something made from the date.
|
StopSpam

msg:440528 | 4:47 pm on Aug 12, 2003 (gmt 0) |
ok yuour talking php in working in perl can i then still use: $rank = rand(4, 10);
|
Glacai

msg:440529 | 4:59 pm on Aug 12, 2003 (gmt 0) |
Sorry, yeah its nearly the same except it only takes max number, you don't need to call srand but I would look it up to find the best way to seed it. $rank = rand(7) + 4;
|
StopSpam

msg:440530 | 7:01 pm on Aug 12, 2003 (gmt 0) |
hi this is working i now get : random number is:5.18599890451878 random number is:7.94239684566855 random number is:10.9349901601672 i use this to remove the . and nunmbers behind first number: $rank = rand(7) + 2; $c = "$rank"; $d = unpack("A1" , $c); print "$d \n"; i now get clean numbers from 1 hill 9 thanks i could not have done it without you ... this is a nice code snippet for a random number ;-)
|
Glacai

msg:440531 | 10:00 pm on Aug 12, 2003 (gmt 0) |
Or even, $rank = int(rand(7)) + 2;
|
StopSpam

msg:440532 | 11:24 pm on Aug 12, 2003 (gmt 0) |
yes thats far better then how i thit it ... this is perfect ... your a real pro ;-) were thit you learned this line? i got the oreily perl cook book but it has not these codedings its limmited when it comes to radomnness in fact i havent seen this code before thank you ....
|
|