1

Topic: Rand() in parser?

When i do rand() or array_rand() in the parser.php it always returns the same thing (atleast in a single post)

example: if i replace [num] with rand(0, 9) this: [num][num][num][num] will return something like 6666 or 8888 or maybe 1111, never different numbers.
Is this possible to "fix" ?

2

Re: Rand() in parser?

Depending on the code leading up.  mt_rand is much better then rand, as rand will provide predictable results.

3

Re: Rand() in parser?

Thanks for the tip, didnt know Mersenne Twister was implented..
It didnt help though :\

Re: Rand() in parser?

Did you seed the random number generator? mt_srand()?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5

Re: Rand() in parser?

Well, that is not needed in PHP 4.2..  plus i use it at another place without seeding and there it gives different results.

6

Re: Rand() in parser?

The parser will probably only run once...if its called only once...

so if your like....

$string = str_replace("string", mt_rand(1,100), $string)

...its gonna be the same number throughout the entire process