The question is not very clear as to what exactly you want. If you want to generate such a string randomly you can do something like:
$length = 20;
$characters = ‘0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ’;
$random_string = "";
for ($p = 0; $p < $length; $p++) {
$random_string .= $characters[mt_rand(0, strlen($characters))];
}
To ensure the newly generated token is unique, you'll have to keep track of all the previously generated tokens and perform a check.
codaddict
2010-03-04 08:00:43