I have tried it standalone many many times and i got no ID with illegal character. Well, But when the code below working on my website, it is generating illegal characters like: XY�DV3VD, L6XÝOMJ3
The output must consist of [A-Z] and [0-9]. How this could be? Thanks for ideas.
function uniqeeID($len){
//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1));
//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));
//Removing any . or / and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
//finally I take the first $len characters from the $rnd_id
$rnd_id = strtoupper(substr($rnd_id,0,$len));
return $rnd_id;
}