【问题标题】:Displaying feed with the correct html character entities使用正确的 html 字符实体显示提要
【发布时间】:2011-03-28 11:58:13
【问题描述】:

我的 Feed 已经分解为我需要的内容。该内容的一部分包含诸如&\;"\; 之类的内容。

我正在使用 PHP 的 str_replace() 来查找并将它们替换为正确的 html 字符实体(例如 &)。但是,它不会找到这个:

 $find = array('&\;', '"\;', '\;');

我会像这样替换它们:

 $replace = array('&', '"', '&#59;');

为了让函数找到它们,我缺少什么?


<ul>
    <li>Story Time with Captain Fishbones</li>
    <li>Flashback</li>
    <li>The Office</li>
    <li>The Life &amp\; Music of Ella Fitzgerald</li>
    <li>Circus in the Park</li>
    <li>Symphonicity</li>
    <li>Wreck of the Dictator</li>
    <li>Fireworks</li>  
</ul>
<h3>Thursday, Aug 12</h3>
<ul>
    <li>Historic Villages Tour</li>
    <li>The Janitors</li>
    <li>Mitchell&#039\;s Mayhem</li>
    <li>&quot\;1607 First Landing&quot\; by Chip Fortier</li>
    <li>Adam Queen followed by Randy Hermoso</li>

    <li>The Life &amp\; Music of Ella Fitzgerald</li>
    <li>Shipwrecks and Ghost Lore</li>
    <li>Black White Blues</li>
    <li>Wreck of the Dictator</li>
</ul>

【问题讨论】:

  • 您的数据是什么样的?您能否提供数据的 sn-p 并解释您实现了什么?
  • 你可以添加你当前的 php 代码吗?您的函数调用中可能有错误。
  • 我的回答对你有帮助吗?

标签: php string html-entities


【解决方案1】:

使用html_special_chars() 打印内容。 另外我认为你的 $find 变量有错误的转义序列。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-15
    • 2011-09-02
    • 2020-04-07
    • 1970-01-01
    • 2015-05-12
    • 1970-01-01
    • 2015-12-13
    • 2018-06-02
    相关资源
    最近更新 更多