我需要从我的内容中删除所有html元素.内容示例:
"<p><img alt=\"\" src=\"/ckeditor_assets/pictures/1/content_twitter-sink.jpg\" style=\"width: 570px; height: 399px;\" /></p>\r\n\r\n<h3 style=\"font-size: 1.38462em; margin: 1em 0px 0px; font-weight: 600; line-height: 1.2; font-family: freight-sans-pro,sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizelegibility; color: rgb(46,46,46);\">Soraya Calavassy,communications manager at the Award in Australia, shares her organisation's experience piloting our new global visual identity.</h3>\r\n\r\n<p style=\"margin: 0.5em 0px 0px; text-rendering: optimizelegibility; font-size: 1.30769em; line-height: 1.3; color: rgb(78,78,78); font-family: freight-sans-pro,sans-serif;\">"While Australia has a very strong brand locally,there are some great benefits for incorporating"
当显示帖子我使用raw,它确实给了我需要的输出.但我需要制作摘录.为此,我需要删除所有HTML标记,甚至删除图像.但是,当我使用消毒时,它不会删除图像.如果我使用strip_tags,它将删除图像,但它会添加'撇号,& nbsp;因此,如何获得一个没有图像和没有& nbsp;的清晰摘录.东西?
解决方法
尝试strip_tags(text).html_safe