Forum Moderators: coopster
$UNIQUENUM = strval(rand(10000000, 44444444));
My question is, lets say after several million uploads is their a chance that the same number could be generated, creating a duplicate named picture on the server or worse, overwriting a photo?
If you are that worried, perhaps try putting the numbers in a database, then use an if else statement and check if the number is in use before applying it to the image. And of course if it is, generate another number.
>>>first column:
1
2
3
4
or
00001
00002
00003
whatever
Use the little square autocomplete thing dragging the lower right hand corner and make it fill in all 65536 possibilities
>>>second column
(RAND) or whatever it is from excel - select insert formula or whatever and it will be in there
drag and drop so the whole column is filled
then select both columns and sort by the rand number column
now you have a list of 65000 random numbers all with no repeats.
You can do numbers higher than 65000 - just start that way - and you can increment anyway you want.
I use sort by rand all the time.
very useful.
However - if you know how to use databases - that way might be better - I guess my way is technically a databse.
then I will as per gary_h suggestion indeed use a DB and a query
<<<
for($i = 0; $i < 6; $i++) {
$type[1] = "a¦b¦c¦d¦e¦f¦g¦h¦i¦j¦k¦l¦m¦n¦p¦q¦r¦s¦t¦u¦v¦x¦w¦y¦z";
$type[2] = "1¦2¦3¦4¦5¦6¦7¦8¦9";
$randType = rand(1, 2);
$type = explode("¦", $type[$randType]);
$max = count($type);
// Rand result
$randChar = rand(0, $max);
$rand .= $type[$randChar];
}
>>>