This code is untested... let me know if it doesn't work.
<?php
function StringGenerator($str_len){
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$chr = strlen($chars)-1;
for($i=0;$i<$str_len;$i++) {
mt_srand((double)microtime()*1000000); // unnecessary for 4.2.0 and later...
$randstring .= $chars[mt_rand(0, $chr)];
}
return $randstring;
}
?>
::edit::
Jinx! LOL... I'll leave mine up, even though it's almost identical. The only real difference is that mine gives you the option of changing the length by passing a different value to the function. Plus, it uses mt_rand(), which is faster than rand(). That's really a moot point for such a simple function.