我正试图摆脱卷曲的撇号(我想象的那些粘贴在某种富文本文档上),我似乎正在遇到路障.以下代码对我不起作用.
$word = "Today’s"; $search = array('„','“','’'); $replace = array('"','"',"'"); $word = str_replace($search,$replace,htmlentities($word,ENT_QUOTES)); What I end up with is $word containing 'Today’s'.
当我从$search数组中删除&符号时,会发生替换,但显然,由于&符号保留在字符串中,因此显然不会完成任务.为什么str_replace在遇到&符号时会失败?
为什么不这样做:
原文链接:https://www.f2er.com/php/135337.html$word = htmlentities(str_replace($search,$word),ENT_QUOTES);
?