public static function encodepath($text, $type = null)
    {
        $text = preg_replace('#[`\'"\^~{}\[\]()]#', '', $text);
        $text = preg_replace('#[\n\s\/\p{P}]#u', '-', $text);

        if ($type === self::UNICODE) {
            $text = preg_replace('#[^\d\p{L}\p{N}\-]#u', '', $text);
        } elseif ($type === self::ASCII) {
            $text = preg_replace('#[^\d\p{L}\-]#u', '', $text);
            $text = self::encodepath($text);
        } else {
            $text = Helper::toAscii($text);
            $text = preg_replace('#[^a-z\d\-]#i', '', $text);
        }

        return trim(preg_replace('#--+#', '-', $text), '-');
    }
public static function encodepath($text, $type = null)
    {
        $text = preg_replace('#[`\'"\^~{}\[\]()]#', '', $text);
        $text = preg_replace('#[\n\s\/\p{P}]#u', '-', $text);

        if ($type === self::UNICODE) {
            $text = preg_replace('#[^\d\p{L}\p{N}\-]#u', '', $text);
        } elseif ($type === self::ASCII) {
            $text = preg_replace('#[^\d\p{L}\-]#u', '', $text);
            $text = self::encodepath($text);
        } else {
            $text = Helper::toAscii($text);
            $text = preg_replace('#[^a-z\d\-]#i', '', $text);
        }

        return trim(preg_replace('#--+#', '-', $text), '-');
    }
public static function encodepath ( $ text , $ type = null ) { $ text = preg_replace ( '#[`\'"\^~{}\[\]()]#' , '' , $ text ) ; $ text = preg_replace ( '#[\n\s\/\p{P}]#u' , '-' , $ text ) ; if ( $ type === self :: UNICODE ) { $ text = preg_replace ( '#[^\d\p{L}\p{N}\-]#u' , '' , $ text ) ; } elseif ( $ type === self :: ASCII ) { $ text = preg_replace ( '#[^\d\p{L}\-]#u' , '' , $ text ) ; $ text = self :: encodepath ( $ text ) ; } else { $ text = Helper :: toAscii ( $ text ) ; $ text = preg_replace ( '#[^a-z\d\-]#i' , '' , $ text ) ; } return trim ( preg_replace ( '#--+#' , '-' , $ text ) , '-' ) ; }
Convert text to URL format

@param string $text
@param int    $type
@return string
Convert text to URL format