update page now

Voting

: seven minus zero?
(Example: nine)

The Note You're Voting On

contact at einenlum dot com
2 years ago
Keep in mind that now srand is an alias for mt_srand, but they behaved differently before. This means you should not follow the documentation of srand, but the one of mt_srand, when using srand.
To reset the seed to a random value, `mt_srand(0)` (or `srand(0)`) doesn't work. It sets the seed to 0. To reset the seed to a random value you must use `mt_srand()` (or `srand()`).
<?php
$arr = [0, 1, 2, 3, 4];
srand(1); // or mt_srand(1) as they are now aliases
$keys = array_rand($arr, 2); // not random as expected
srand(0); // or mt_srand(0) as they are now aliases
$keys = array_rand($arr, 2); // not random either!
srand(); // or mt_srand() as they are now aliases
$keys = array_rand($arr, 2); // random again
?>

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /