public static function randStr($len = 6, $format = 'ALL')
    {
        switch (strtoupper($format)) {
            case 'ALL':
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~';
                break;
            case 'CHAR':
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@#~';
                break;
            case 'NUMBER':
                $chars = '0123456789';
                break;
            default :
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~';
                break;
        }
        mt_srand((double)microtime() * 1000000 * getmypid());
        $randStr = "";
        while (strlen($randStr) < $len)
            $randStr .= substr($chars, (mt_rand() % strlen($chars)), 1);
        return $randStr;
    }
public static function randStr($len = 6, $format = 'ALL')
    {
        switch (strtoupper($format)) {
            case 'ALL':
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~';
                break;
            case 'CHAR':
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@#~';
                break;
            case 'NUMBER':
                $chars = '0123456789';
                break;
            default :
                $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~';
                break;
        }
        mt_srand((double)microtime() * 1000000 * getmypid());
        $randStr = "";
        while (strlen($randStr) < $len)
            $randStr .= substr($chars, (mt_rand() % strlen($chars)), 1);
        return $randStr;
    }
public static function randStr ( $ len = 6 , $ format = 'ALL' ) { switch ( strtoupper ( $ format ) ) { case 'ALL' : $ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~' ; break ; case 'CHAR' : $ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-@#~' ; break ; case 'NUMBER' : $ chars = '0123456789' ; break ; default : $ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@#~' ; break ; } mt_srand ( ( double ) microtime ( ) * 1000000 * getmypid ( ) ) ; $ randStr = "" ; while ( strlen ( $ randStr ) < $ len ) $ randStr .= substr ( $ chars , ( mt_rand ( ) % strlen ( $ chars ) ) , 1 ) ; return $ randStr ; }
generate random string of 6 digits

@param int    $len
@param string $format
@return string
generate random string of 6 digits