Generate a unique string out of numeric value

This is how you can create a (pretty) unique string that changes constantly, mening not being almost the same as the previously generated string. I needed something that needs to be unique for a year and not look the same as the previously generated string/key, and that was not that very obvious that it was based on the unix timestamp. So I removed the first digit, to keep it short, you could keep that unique over the years if needed. Then I added the first digit in the microtime() result, to make it generate at least 10 different keys per second. Then I rearranged the digit positions abit to make two closely generated keys to llok completely different.

 

<?php
 
// The microtime 1574433196.5298
$time = microtime('return_float');

//Generate the unique input by mixing positions a bit
$test = substr($time, 11, 1). substr($time, 9, 1) . substr($time, 5, 4) . substr($time, 1, 4);
//$test = substr($time, 11, 1). substr($time, 9, 1) . substr($time, 5, 4) . substr($time, 0, 5); //a more unique combination over the years

//Print the input and the base 36 with uppercase letters
echo "$test => ". strtoupper(base_convert($test,10,36))."<br>";

//Just printing the numeric input block by block
echo "$time<br>".substr($time, 11, 1)." ".substr($time, 9, 1)." ".substr($time, 5, 4)." ".substr($time, 1, 4);
//echo "$time<br>".substr($time, 11, 1)." ".substr($time, 9, 1)." ".substr($time, 5, 4)." ".substr($time, 0, 5); //a more unique combination over the years
?>

 

The output will be like this, where the unique string or key becomes 2WPVTMT from the microtime 1574433196.5298
1633195744 => R0D1WG
1574433196.1
1 6 3319 5744

So generating some strings after each other will look like this:
1574433196.1   => R0D1WG
1574433196.2   => 17JQIU8
1574433196.3   => 1O33ZS0
1574433196.4   => 24MHGPS
Knowledge keywords: