public function normalizeName($name, $separator = '_')
    {
        if (strlen($separator) == 0) {
            return preg_replace('|[^a-z0-9]|i', '', $name);
        }

        $s = $separator[0];
        $name = preg_replace('|[^a-z0-9\\'.$s.']|i', $s, $name);
        $name = trim($name, $s);
        $name = preg_replace('|\\'.$s.'{2,}|', $s, $name);

        return $name;
    }
public function normalizeName($name, $separator = '_')
    {
        if (strlen($separator) == 0) {
            return preg_replace('|[^a-z0-9]|i', '', $name);
        }

        $s = $separator[0];
        $name = preg_replace('|[^a-z0-9\\'.$s.']|i', $s, $name);
        $name = trim($name, $s);
        $name = preg_replace('|\\'.$s.'{2,}|', $s, $name);

        return $name;
    }
public function normalizeName ( $ name , $ separator = '_' ) { if ( strlen ( $ separator ) == 0 ) { return preg_replace ( '|[^a-z0-9]|i' , '' , $ name ) ; } $ s = $ separator [ 0 ] ; $ name = preg_replace ( '|[^a-z0-9\\' . $ s . ']|i' , $ s , $ name ) ; $ name = trim ( $ name , $ s ) ; $ name = preg_replace ( '|\\' . $ s . '{2,}|' , $ s , $ name ) ; return $ name ; }
Normalize field or identifier name. Can also be used in URL normalization.
This will replace all non alpha-numeric characters with separator.
Multiple separators in a row is replaced with one.
Separators in beginning and at the end of name are removed.

Sample input:  "Hello, Dear Jon!"
Sample output: "Hello_Dear_Jon"

@param string $name      String to process
@param string $separator Character acting as separator

@return string Normalized string
Normalize field or identifier name . Can also be used in URL normalization . This will replace all non alpha - numeric characters with separator . Multiple separators in a row is replaced with one . Separators in beginning and at the end of name are removed .