如何从数据库中以
的形式检索数据<p>&nbsp;</p>
<p><span style="\">Classic Developers, a destination that offers every one luxurious and fulfilling yet affordable lifestyle. It is one of the emerging real estate developers in the country having diverse range of activities in varied business domain. We are a certified company having large scale projects in progress.</span></p>
<p><span style="\"><br /></span></p>
<p><span style="\">Classic Developers with its dynamic professional work force and uncompromising attitude in terms of construction methodologies and quality control procedures, we offer you Efficient, Elegant and Economical place, which will be called your home, your happiness. We are here not only for a residential place but to fulfill your dream of having a home with modern day comfort and soothing ambience. We not only offer modern structures with latest amenities but ensure all the valued customers with Earthquake resistant and VASTU compliant construction.</span></p>
<p>&nbsp;</p>
我需要没有html标签和其他风格的值。只有我想要的是其中的文字。 我可以用php检索它吗。
提前致谢。
答案 0 :(得分:7)
http://php.net/manual/en/function.strip-tags.php
从数据库获得它之后,在它回显之前运行此函数:
$content = strip_tags($content);
修改强>
编辑问题是为了显示特殊字符而不是原始HTML。如果它的是,请尝试这种方式:
$content = strip_tags(htmlspecialchars_decode($content));
答案 1 :(得分:1)
从数据库中获取列后,您可以使用strip_tags()
方法清理输入。
答案 2 :(得分:0)
如果您不想要@Ben Griffiths建议的简单解决方案,并且您仍然需要纯DB处理,那么请查看正则表达式 - 请参阅MySQL regex replace?