function randCode($size = 6){ $code = ""; $str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; for($i=0;$i<$size;$i++){ $key = rand(0,62); $code.=substr($str,$key,1); } return $code; }