相关疑难解决方法(0)

PHP - 摆脱卷曲撇号

我正试图摆脱卷曲的撇号(我想象的那些粘贴在某种富文本文档中),我似乎正在遇到路障.以下代码对我不起作用.

$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'.
Run Code Online (Sandbox Code Playgroud)

当我从$ search数组中删除&符号时,会发生替换,但显然,由于&符号保留在字符串中,因此显然无法完成工作.为什么str_replace在遇到&符时失败了?

php string escaping

7
推荐指数
2
解决办法
7523
查看次数

标签 统计

escaping ×1

php ×1

string ×1