Sanitize Key : Lowercase Accentless $string, Special Characters $replacement

function sanitize_key( $string, $replacement = '_' )
{
    // Lowercase and remove accents
    $string = htmlentities( trim( strtolower( strval( $string ) ) ), ENT_NOQUOTES );
    $string = preg_replace( '/&([a-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);/', '$1', $string );
    $string = preg_replace( '/&([a-z]{2})(?:lig);/', '$1', $string );
    $string = preg_replace( '/&[^;]+;/', $replacement, $string );
    // Replace non-alphanumeric characters
    return preg_replace( '/[^a-z0-9]+/', $replacement, $string );
}