Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

srand(3) [php man page]

SRAND(3)								 1								  SRAND(3)

srand - Seed the random number generator

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

SYNOPSIS
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)
Man Page

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PHP: at mm:ss.00

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)
Discussion started by: perleo
1 Replies

2. UNIX for Dummies Questions & Answers

Question on Ramdom Number

Hi all, How do I get a ramdom number from 11 to 20 in every loop (loop runs 1000 times). please let me know. Thanks (14 Replies)
Discussion started by: jingi1234
14 Replies

3. Shell Programming and Scripting

How to remove the lines from file using perl

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)
Discussion started by: dipakg
5 Replies

4. Shell Programming and Scripting

How to remove the specific lines from file using perl

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)
Discussion started by: dipakg
4 Replies

5. Shell Programming and Scripting

Need specialized random string generator script

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)
Discussion started by: vajrajames
5 Replies

6. UNIX for Dummies Questions & Answers

Random selection of subset of sample from file

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)
Discussion started by: biopsy
7 Replies

7. UNIX for Dummies Questions & Answers

I need help

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)
Discussion started by: suppliernr1
1 Replies

8. Shell Programming and Scripting

awk (or) UNIX random RGB colors generator?

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)
Discussion started by: jacobs.smith
2 Replies