SRAND(3) 1 SRAND(3)srand - Seed the random number generatorSYNOPSIS
void srand ([int $seed])
DESCRIPTION
Seeds the random number generator with $seed or with a random value if no $seed is given.
Note
As of PHP 4.2.0, there is no need to seed the random number generator with srand(3) or mt_srand(3) as this is now done automati-
cally.
PARAMETERS
o $seed
- Optional seed value
RETURN VALUES
No value is returned.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 4.2.0 | |
| | |
| | The $seed becomes optional and defaults to a |
| | random value if omitted. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
srand(3) example
<?php
// seed with microseconds
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
$randval = rand();
?>
SEE ALSO rand(3), getrandmax(3), mt_srand(3).
PHP Documentation Group SRAND(3)
Check Out this Related Man Page
MT_SRAND(3) 1 MT_SRAND(3)mt_srand - Seed the better random number generatorSYNOPSIS
void mt_srand ([int $seed])
DESCRIPTION
Seeds the random number generator with $seed or with a random value if no $seed is given.
Note
There is no need to seed the random number generator with srand(3) or mt_srand(3) as this is done automatically.
PARAMETERS
o $seed
- An optional seed value
RETURN VALUES
No value is returned.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.2.1 | |
| | |
| | The Mersenne Twister implementation in PHP now |
| | uses a new seeding algorithm by Richard Wagner. |
| | Identical seeds no longer produce the same |
| | sequence of values they did in previous versions. |
| | This behavior is not expected to change again, |
| | but it is considered unsafe to rely upon it none- |
| | theless. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
mt_srand(3) example
<?php
// seed with microseconds
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
mt_srand(make_seed());
$randval = mt_rand();
?>
SEE ALSO mt_rand(3), mt_getrandmax(3), srand(3).
PHP Documentation Group MT_SRAND(3)
I have these two times in the format mm:ss.00
e.g. 25:45.04
25 mins 45 sec 04 mili sec.
Can php take 2 of these out out of mysql and add them and print the result ? (1 Reply)
Can anyone tell me what could be the solution to following :
I have one .txt file which contains some seed information. This seed may appear multiple time in the file so what I want do is if this seed appears again in the file then that line should be removed.
here is the contents of .txt... (5 Replies)
Can anyone tell me what could be the solution to following :
I have one .txt file which contains some "seed" information. This seed may appear multiple time in the file so what I want do is if this seed appears again in the file then that line should be removed.
Please provide the script code... (4 Replies)
Hi,
I need a script that will generate a set of random strings in sequence, with the ability to predetermine the length, quantity, and alphabet of individual string, and to use the outputs of earlier strings in the sequence to define the parameters of later strings. For examples, I might want... (5 Replies)
Hello
Could you please help me to find a code that can randomly select 1224 lines from a file of 12240 and make tn output with 1224 line each.
my input is txt file with 12240 lines like :
13474 999003507 0 0 2 -9
13475 999003508 0 0 2 -9
13476 999003509 0 0 1 -9
13477 999003510 0 0 1 -9
... (7 Replies)
hello, i am a newbie and i really need your help
i have an centos 6.5 and i wonder if i can create a list with random 4 letters :
gdjf
ornc
tyrn
jfdn
nofd
etc....
if it can be done , i will really apreciate your help ! THANKS !!!
ohhh...i forgot .... i want to use all... (1 Reply)
Dear UNIX Friends,
I was wondering if there is a random RGB color generator or any function in any unix platforms.
Please share your ideas.
Thanks (2 Replies)