How can I generate a 6 digit unique number?
If you want it to start at 000001
and go to 999999
:
$num_str = sprintf("%06d", mt_rand(1, 999999));
Mind you, it's stored as a string.
$six_digit_random_number = random_int(100000, 999999);
As all numbers between 100,000 and 999,999 are six digits, of course.