0

如何从数据格式为的数据库中检索数据

<p> </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> </p>

我需要没有 html 标签和其他样式的值。只有我想要的是里面的文字。我怎样才能用 php 检索它。

提前致谢。

4

3 回答 3

7

http://php.net/manual/en/function.strip-tags.php

一旦你从数据库中得到它,在你回显它之前在它上面运行这个函数:

$content = strip_tags($content);

编辑

该问题已被编辑以显示特殊字符而不是原始 HTML。如果这种风格,请尝试以下方式:

$content = strip_tags(htmlspecialchars_decode($content));
于 2012-04-12T10:33:13.890 回答
1

从数据库中获取列后,您可以使用strip_tags()方法来清理输入。

于 2012-04-12T10:35:05.573 回答
0

如果您不想要@Ben Griffiths 建议的简单解决方案并且您仍然需要纯数据库处理,那么请查看正则表达式 - 请参阅MySQL regex replace?

于 2012-04-12T10:35:13.390 回答