I tried your code and I get a different number each time. The only thing I can think of is that you have a very old version of PHP. There's a version with a bug in the rand() function.
It that's the issue, you could try this:
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
return rand();
Another option is to use uniqid() instead of rand(). It uses microtime() for the seed and should give you a unique string each time. It's a better option if you want a string that's truly unique (say, for a filename), though the string will include letters as well as numbers.
If you don't want the letters, you can do this:
[ed. note: BobRay last edited this post 10 years, 4 months ago.]