Auto incremented alphanumeric string.
Posted: Fri Dec 03, 2010 3:23 am
I need a way to create a 8 character length string that gets auto incremented every time a new on is created.
it should look something like this mKa8dU01.
I found this on another forum, its for a URL shortener.
but I have no idea how to use it or if I can even apply it to what I need. Any care to explain what the above actually does or knows how i can get the results I need?
Thanks
it should look something like this mKa8dU01.
I found this on another forum, its for a URL shortener.
Code: Select all
for($counter=0; $counter < 10000; $counter+=1) {
$shorturl = "";
$tmp_count = $counter;
for($i=5;$i>=0; $i--) {
$tmp = floor($tmp_count/pow(36,$i));
$tmp_count -= $tmp*pow(36,$i);
if($tmp < 10) {
$shorturl .= chr($tmp + 48);
} else {
$shorturl .= chr($tmp + 87);
}
}
}
Thanks