php 生成2个字母或数字组合
/** * 生成2个字母 * @param $len * @param null $chars * @return string */ public static function getRandomString($len, $chars=null) { if (is_null($chars)){ //$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; } mt_srand(10000000*(double)microtime()); for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++){ $str .= $chars[mt_rand(0, $lc)]; } return $str; }