Question may be off topic, but I was just wondering if this wouldn't be a nice and simple random number function. It's supposed to give a random Number from 0 to $max
:
function randomNumber($max){
((int)(1000000000000 / microtime())) % ($max+1);
}
If I'm not missing something pretty obvious here this should work, shouldn't it? But, the next question would be: Are the numbers created here really random? When I simulate 1'000'000 dice rolls, I get something like the following:
Array
(
[1] => 166520
[2] => 166619
[3] => 166522
[4] => 167001
[5] => 166512
[6] => 166826
)
Why I'm asking this question is: I've read that it's not possible to create a truly random number, so I started thinking and this function seems to give quite random results, without being complicated at all. So am I missing something here?