查找和替换 php 中的特殊字符

Finding and replacing special characters in php

编码使这件事很难解释。我正在使用 PHP 从 XML 文件中获取字符串。当我回显它时,我看到一个黑色的小圆圈: • 或 • 。哦,Whosebug 渲染了这些,抱歉。我的意思是说它是 ascii 字符 "bull" 或“#8226”

echo $str;
gets me:
[CIRCLE] wordswords [CIRCLE] more words [CIRCLE] still more words

如何使用 PHP 找到这个字符?我想在上面爆炸。圆圈搜不到,搜8226或者circ也不行。我必须使用 urlencode 吗?

$str=url_encode($str);
$str=str_replace(%E2%80%A2,'-CIRCLE-',$str);
$str=url_decode($str);
$str=explode('-CIRCLE-');

或者有更高效的方法吗?

查看此线程:Bullet "•" in XML。我想这会帮助你找到答案。