0

What is the shortest unique ID that can be created with PHP but without using a database? I guess it's something based on date+time (24 hour time format?) but how short can it be?

Robert
  • 152
  • 1
  • 5
  • Depends on how often you need it. – Tim3880 May 31 '15 at 17:50
  • This question is a solution looking for a problem to solve. Why dont you state the problem and give some context if you want some valuable input ? – YvesLeBorg May 31 '15 at 17:53
  • How many unique ids are you going to need? That will determine the number of bits that you must have to make sure that there will be enough unique ids. – James Newton May 31 '15 at 18:10

1 Answers1

1

For an PHP inbuilt solution you could look into uniqid (http://php.net/manual/en/function.uniqid.php).

$id = uniqid('',true);

Alternatively you could create a UUID. For example see: PHP function to generate v4 UUID

Community
  • 1
  • 1
Jim
  • 22,354
  • 6
  • 52
  • 80