print preg_replace( '/([а-яё])/iu', idn_to_ascii( "$1" ), 'мой-сайт.рф' );
$str = 'мой-сайт.рф';
$pattern = '/([-а-яё.]+)/iu';
echo preg_replace_callback($pattern, function($matches){
return idn_to_ascii( $matches[0], IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
}, $str );
// на выходе
// xn----8sbzclmxk.xn--p1ai