rfc:rng_extension
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
rfc:rng_extension [2021/09/03 13:53] zeriyoshi fix: missing CSPRNG functions. |
rfc:rng_extension [2021/09/03 14:02] zeriyoshi add more example |
||
---|---|---|---|
Line 90: | Line 90: | ||
* shuffleArray() | * shuffleArray() | ||
* shuffleString() | * shuffleString() | ||
+ | |||
+ | This class can be used in the following way. | ||
+ | |||
+ | <code php> | ||
+ | // functions | ||
+ | mt_srand(1234); | ||
+ | mt_rand(); // generate random number | ||
+ | mt_rand(1, 10); // generate random number in range | ||
+ | str_shuffle(" | ||
+ | $arr = range(1, 10); | ||
+ | shuffle($arr); | ||
+ | |||
+ | // object | ||
+ | $mt = new Random\NumberGenerator\MT19937(1234); | ||
+ | $mt-> | ||
+ | $random = new Random($mt); | ||
+ | $random-> | ||
+ | $random-> | ||
+ | $random-> | ||
+ | </ | ||
The Random class accepts an instance that inherits from Random\NumberGenerator as a constructor argument. | The Random class accepts an instance that inherits from Random\NumberGenerator as a constructor argument. |
rfc/rng_extension.txt · Last modified: 2022/04/26 06:45 by zeriyoshi