【发布时间】:2014-12-08 05:36:17
【问题描述】:
我只想从 php 字符串中提取文本。
这个 php 字符串包含 html 代码,如标签等。
所以我只需要这个字符串中的一个简单文本。
这是实际的字符串:
<div class="devblog-index-content battlelog-wordpress">
<p><strong>The celebration of the Recon class in our second </strong><a href="http://blogs.battlefield.com/2014/10/bf4-class-week-recon/" target="_blank">BF4 Class Week</a><strong> continues with a sneaky stroll down memory lane. Learn more about how the Recon has changed in appearance, name and weaponry over the years…</strong></p>
<p> </p>
<p style="text-align:center"><a href="http://eaassets-a.akamaihd.net/battlelog/prod/954660ddbe53df808c23a0ba948e7971/en_US/blog/wp-content/uploads/2014/10/bf4-history-of-recon-1.jpg?v=1412871863.37"><img alt="bf4-history-of-recon-1" class="aligncenter" src="http://eaassets-a.akamaihd.net/battlelog/prod/954660ddbe53df808c23a0ba948e7971/en_US/blog/wp-content/uploads/2014/10/bf4-history-of-recon-1.jpg?v=1412871863.37" style="width:619px" /></a></p>
我想从字符串中显示这个:
The celebration of the Recon class in our second BF4 Class Week continues with a sneaky stroll down memory lane. Learn more about how the Recon has changed in appearance, name and weaponry over the years…
实际上这个文本将被放置在元描述标签中,所以我不需要在元标签中添加任何 HTML。 我该怎么做?关于这项技术的任何想法和想法?
【问题讨论】:
-
用strip_tags()删除所有html标签
-
使用 strip_tags(),查看手册,您将获得有关如何使用它以及它的作用的详细信息。
标签: php