function uid($n, $len1=5, $len2=15, $base=36) { $id_part = base_convert($n, 10, $base); $rand_part = str_shuffle('abcdefghijklmnopqrstuvwxyz0123456789'); return sprintf("%0".$len1."s-%.".$len2."s", $id_part, $rand_part); }
source: http://stackoverflow.com/questions/2377633/how-create-an-unique-20-single-byte-token-key-id-on-php