我想要将任何特殊字符转换为它的原始值,我正在尝试这个函数,但它不起作用。这是我的代码。
$text = "Tuscaloosa County – Hunting and Timber Invest";
echo $html = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");发布于 2019-07-04 17:57:41
我不知道这是不是你想要的,但试一试
$text = "Tuscaloosa County – Hunting and Timber Invest"; echo $html =mb_convert_encoding($text, 'UTF-8');
发布于 2019-07-04 18:13:34
尝试此清理函数
function clean($string) {
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
}
$text = "Tuscaloosa County – Hunting and Timber Invest";
echo $html = clean($text);发布于 2019-07-04 18:13:48
1。尝试使用next:
$text = "Tuscaloosa County – Hunting and Timber Invest";
$html_1 = utf8_encode($text);
$html_2 = iconv('ISO-8859-1', 'UTF-8', $text);
$html_2 = mb_convert_encoding($text, 'UTF-8', 'ISO-8859-1');或
$text = "Tuscaloosa County – Hunting and Timber Invest";
$html_1 = utf8_decode($text);
$html_2 = iconv('UTF-8', 'ISO-8859-1', $text);
$html_2 = mb_convert_encoding($text, 'ISO-8859-1', 'UTF-8');2。这样的话:
$html= mb_convert_encode($text,'HTML-ENTITIES','UTF-8'); https://stackoverflow.com/questions/56884856
复制相似问题