使用正确的 html 字符实体显示 feed
我的提要已经分解为我需要的内容。该内容的一部分包含诸如 &\;
和 "\;
之类的内容。
我使用 PHP 的 str_replace()
来查找和替换它们是正确的 html 字符实体(例如 &
)但是,它不会找到这个:
$find = array('&\;', '"\;', '\;');
我会像这样替换它们:
$replace = array('&', '"', ';');
为了该功能我缺少什么?找到他们?
<ul>
<li>Story Time with Captain Fishbones</li>
<li>Flashback</li>
<li>The Office</li>
<li>The Life &\; 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'\;s Mayhem</li>
<li>"\;1607 First Landing"\; by Chip Fortier</li>
<li>Adam Queen followed by Randy Hermoso</li>
<li>The Life &\; Music of Ella Fitzgerald</li>
<li>Shipwrecks and Ghost Lore</li>
<li>Black White Blues</li>
<li>Wreck of the Dictator</li>
</ul>
I have feed that's already broken down into the content I need. Part of that content contains things such as &\;
and "\;
.
I'm using PHP's str_replace()
to find and replace them to be their correct html character entities (ex. &
). However, it won't find this:
$find = array('&\;', '"\;', '\;');
And I would replace them like this:
$replace = array('&', '"', ';');
What am I missing in order for the function to find them?
<ul>
<li>Story Time with Captain Fishbones</li>
<li>Flashback</li>
<li>The Office</li>
<li>The Life &\; 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'\;s Mayhem</li>
<li>"\;1607 First Landing"\; by Chip Fortier</li>
<li>Adam Queen followed by Randy Hermoso</li>
<li>The Life &\; Music of Ella Fitzgerald</li>
<li>Shipwrecks and Ghost Lore</li>
<li>Black White Blues</li>
<li>Wreck of the Dictator</li>
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 html_special_chars() 打印内容。
另外我认为你的 $find 变量有错误的转义序列。
Use html_special_chars() to print the content.
Also I think that your $find variable has wrong escape sequences.