jose sanchez
jose sanchez

Reputation: 51

html to text in PHP

i need bypass all html tags to text, Im sure is there any way to bypass all html tags to text in format html, I ut my example below:

Example:

<p style="clear: both;"></p>

for

&lt;p style="clear: both;"&gt;&lt;/p&gt;

any function? thanks :)

Upvotes: 0

Views: 142

Answers (2)

Yogesh Suthar
Yogesh Suthar

Reputation: 30488

use strip_tags for removing html tags

$str = strip_tags("your string");

for displaying html tags use htmlspecialchars

htmlspecialchars("<html>something</html>"); // output <html>something</html>

Upvotes: 1

h2ooooooo
h2ooooooo

Reputation: 39550

You're probably searching for htmlentities():

$str = htmlentities('<p style="clear: both;"></p>');
var_dump($str);

or if you want to do it the other way around, use html_entity_decode():

$str = html_entity_decode('&lt;p style="clear: both;"&gt;&lt;/p&gt;');
var_dump($str);

Upvotes: 1

Related Questions