Does it always return the same values, or just sometimes or even most of the time? I've frequently used similar code and get the same values several times especially if there aren't many values to choose between.
The rand() function is not a true random number generator, it's what is called a pseudo-random number generator. It is "seeded" with a mathematically calculated value based on a timestamp (time()). So it's possible that if two calls to rand() are done closely enough together, they would have the same timestamp, and thus the same seed, generating the same pseudo-random number.
It is possible to seed rand() yourself with the srand() function used before the rand() function, although many installations with suhosin block that function.
Some interesting comments in this PHP doc page
http://php.net/manual/en/function.srand.php