从php字符串中删除所有html标签我想显示数据库条目的前110个字符。到目前为止很容易:<?php echo substr($row_get_Business['business_description'],0,110) . "..."; ?>但是上面的条目中有html代码,由客户输入。所以它显示:<p class="Body1"><strong><span style="text-decoration: underline;">Ref no:</span></strong> 30001<strong></stro...显然没有好处。我只想删除所有的html代码,所以我需要从db条目中删除<和>之间的所有内容然后显示前100个字符。任何人的想法?
3 回答
![?](http://img1.sycdn.imooc.com/54584f3100019e9702200220-100-100.jpg)
函数式编程
TA贡献1807条经验 获得超9个赞
使用PHP的strip_tags()函数。
例如:
$businessDesc = strip_tags($row_get_Business['business_description']);$businessDesc = substr($businessDesc, 0, 110);print($businessDesc);
- 3 回答
- 0 关注
- 1210 浏览
添加回答
举报
0/150
提交
取消