i need a $scaler that contains a random number between 4 and 10 ...
in my perl book i found the function SRAND but i have no idea how to use it and there is only one sample code wish is not what i needed it shows radom text whill i need numbers....
$rank = "$random4_10";
How can i make a code that each time i run the script
the scaler $rank contains a different number between 4 to 10
so it may contain: 4 5 6 7 8 9 or 10
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
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.
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
;-)