I want to generate a random 5 digit number for a file name, with exception.
If PHP will generate for example the number 65, I want to be set 00065 (only 5 digit).
I have a array who contains a exception for the generator:
$uploaded_files= array(00178, 49856, 32183, 02004, 01585);
In the array are the file names who already exists, and the number generator is very important to omit them, to avoid possible errors.
Thank you.
I want to generate a random 5 digit number for a file name, with
Share
Consider not to re-invent the wheel, especially when the wheel is available in your language in one way or another. That being said:
Do take note, this kind of implementation can really expensive on collisions really fast, especially if the exception list grows.