【发布时间】:2013-03-06 01:32:17
【问题描述】:
我需要删除从 Petfinder API 返回的描述中的所有 HTML 标记,但我似乎不知道该怎么做。
$data['description'] 保存返回的描述。我在源文件中可以看到是这样的......
<div>some text that gets returned</div>
我尝试过使用strip_tags,我尝试过使用html_entity_decode,但标签不会消失!
我需要去除标签以便截断描述..
有人有什么想法吗?
$data['description'] = (string)$pet->description;
$description = $data['description'];
$description = htmlentities($description);
$description = html_entity_decode($description);
$description = strip_tags($description);
$description = substr($data['description'],0,300);
$description = substr($description,0,strrpos($description,' '));
$description = $description."...";
echo "<span style='text-align: justify; margin: 10px 0px;'>".$description."</span>";
【问题讨论】:
-
显示描述文本..
标签: php html-entities strip-tags