- mb_detect_encoding: documentation ( source)
- preg_replace: documentation ( source)
<?php
$str = " muito bom parabéns 😤 AND r0_.avaliacao = 'Parabéns 😤' ";
$str_encoding = mb_detect_encoding($str, 'auto');
$str_name = iconv($str_encoding, 'UTF-8', $str);
$str_name = preg_replace('/[^\p{L}\p{N}\s]\w/u', '', $str);
$str_name = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'.
'|[\x00-\x7F][\x80-\xBF]+'.
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'.
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S','?', $str );
print($str_name);