2013-12-19 17:19:06
 private function FormatName($string)
    {
        if(!function_exists("get_string_max_length")) {
            require_once("function.string.php");
        }
 
        $str = preg_replace('/[[:^print:]]/', '', $string);
        $str = get_string_max_length($str, 65);
        $str = get_letter_number_underscore($str);
        $str = strtolower($str);
 
        return $this->AccountID . "_" . $str;
 
    }
 
/...........................
 
<?php
 
 
function check_length($string, $min = 0, $max = 255)
{
    if (!$string)
        return false;
    $length = strlen($string);
    if ($length < $min || $length > $max)
        return false;
    else
        return true;
}
 
function getEmptyString($string)
{
    if (isset($string)) {
        return $string;
    } else
        return "";
}
 
function get_string_max_length($string, $maxLength)
{
    if(strlen($string) >= $maxLength)
        $string = substr($string, 0, $maxLength);
    return $string;
}
 
function get_letter_number($string)
{
    // to keep letters & numbers
    $string = preg_replace('/[^a-z0-9]+/i', '_', $string);
    return $string;
}
 
function get_letter_only($string)
{
    // to keep letters only
    $string = preg_replace('/[^a-z]+/i', '_', $string);
    return $string;
}
 
function get_letter_number_underscore($string)
{
    // to keep letters, numbers & underscore
    $string = preg_replace('/[^\w]+/', '_', $string);
    return $string;
}
 
function get_letter_number_underscore2($string)
{
    // same as third example; suggested by @tchrist
    $string = preg_replace('/[\W]+/', '_', $string);
    return $string;
}
?>
Invalid Email or Password