function getRandomString($len, $chars=null)
{
if (is_null($chars)) {
$chars = "abcdefghijklmnopqrstuvwxyz";
}
mt_srand(10000000*(double)microtime()); //mt_srand
for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) {
$str .= $chars[mt_rand(0, $lc)];
}
return $str;
}