如何删除&;nbsp;php中的字符?(str_替换功能不工作)

如何删除&;nbsp;php中的字符?(str_替换功能不工作),php,str-replace,Php,Str Replace,“contentDetails”中包含以下数据: <p>This is data sample.&nbsp;</p><p>Second part of the paragraph.&nbsp;</p> 这是数据示例 该段的第二部分 stru_replace不在这里工作。请看一看 以下是我在php中的xml结构: $xml = <?xml version="1.0" encoding="UTF-8">; $xml =

“contentDetails”中包含以下数据:

<p>This is data sample.&nbsp;</p><p>Second part of the paragraph.&nbsp;</p>
这是数据示例

该段的第二部分

stru_replace不在这里工作。请看一看

以下是我在php中的xml结构:

$xml = <?xml version="1.0" encoding="UTF-8">;
$xml = '<root>';
$xml = '<myData>';
$xml .= <content> . str_replace("&nbsp;", "", htmlentities($_POST[contentDetails])) . </content>
$xml = '</myData>';
$xml = '</root>';
$xml=;
$xml='';
$xml='';
$xml.=。str_replace(“,”,htmlentities($\u POST[contentDetails])。
$xml='';
$xml='';

我假设您的
内容详细信息实际上包含:

<p>This is data sample.&nbsp;</p><p>Second part of the paragraph.&nbsp;</p>

请注意,关联数组键应括在引号中;这将导致现在的警告,但在未来的PHP版本中将是一个错误。

我假设您的
contentDetails
实际上包含:

<p>This is data sample.&nbsp;</p><p>Second part of the paragraph.&nbsp;</p>
请注意,关联数组键应括在引号中;这将导致警告,但在未来的PHP版本中将是错误的。

htmlentities()函数将转换为&;nbsp;——所以试试这个

str\u replace(“,”),htmlentities($\u POST[contentDetails])

函数将htmlentities()转换为&;nbsp;——所以试试这个


str\u replace(“&;nbsp;”,”,htmlentities($\u POST[contentDetails])

尝试了此操作,但仍然没有成功,选中了字段“contentDetails”-它显示为“”。还有其他解决这个问题的建议吗?谢谢。尝试了这个仍然没有运气,检查了“contentDetails”字段-它显示为“”。还有其他解决这个问题的建议吗?谢谢。是的,实际上contentDetails没有$nbsp;试过你的推荐,还是不走运。还有其他的建议或想法来解决这个问题吗?谢谢。@Kyle很抱歉反应太慢,这里已经过了一夜了。如果contentDetails确实包含我在问题中描述的内容,那么这段代码应该可以工作。请参阅此演示:。如果您仍然有问题,您可以尝试修改演示以显示它们吗?这将使调试更容易是的,实际上contentDetails没有$nbsp;试过你的推荐,还是不走运。还有其他的建议或想法来解决这个问题吗?谢谢。@Kyle很抱歉反应太慢,这里已经过了一夜了。如果contentDetails确实包含我在问题中描述的内容,那么这段代码应该可以工作。请参阅此演示:。如果您仍然有问题,您可以尝试修改演示以显示它们吗?这将使提供
var\u dump($\u POST[contentDetails])的结果变得更容易。提供
var\u转储的结果($\u POST[contentDetails])