I don't know how picky you need to be about "random".
PHP doesn't really generate true random numbers.
Usually, it's not an issue ... but now you're talking about the lottery.
You can use a remote service like this to help make your script true random:
Here is their API: http://www.random.org/clients/http/
I imagine there are other services like this. I just picked this because
I've used it before. If randomness quality is not an issue, then nevermind.