Generate 6 random numbers for lottery in PHP
Your algorithm is functional, but is not necessarily very efficient, and it will collide more, and more often if the count of numbers increases.

It's generally neater to start off with a unique set of numbers, and to extract a random selection of those numbers, instead of selecting random numbers, and testing for uniqueness.

PHP makes this relatively neat, because it has a built-in shuffle function (that's essentially doing a Fisher-Yates shuffle using the same random system that you are).

So, get an array of the unique values, shuffle it, take a selection of it, and sort the result:

$count = 6;
$highball = 45;
$numbers = range(0, $highball);
shuffle($numbers);
$drawn = array_slice($numbers, - $count);
sort($drawn);


Note, using named variables instead of constants makes it clearer what you are doing.

See this running on ideone: https://ideone.com/1Hh0y8