Hammad
Hammad

Reputation: 1

php mysql html tags

I am having some trouble with strings which I get from my database. These strings include various html tags in them as well. For example:

"<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard</p>" 

This is what I get from the database. How do I get rid of the <p> tags in it? I have already tried strip_tags and other functions to no avail.

These tags do not show up in the tinymce textareas and the tags work there respective functionalities.

Upvotes: 0

Views: 2480

Answers (3)

daGrevis
daGrevis

Reputation: 21333

strip_tags() if you want to remove HTML and PHP tags.

htmlspecialchars() if you want to keep HTML tags, but remove XSS possibility.

Upvotes: 2

Sumant
Sumant

Reputation: 964

Use this function it will help you

function convertSpecialChars($string) {
    $string = str_replace("&", "&amp;", $string);
    $string = str_replace("\n", "&#xA;", $string);
    $string = str_replace("‘", "&apos;", $string);
    $string = str_replace(">", "&gt;", $string);
    $string = str_replace("<", "&lt;", $string);
    $string = str_replace("“", "&quot;", $string);
    return $string;
}

enjoy...

Upvotes: 2

marc
marc

Reputation: 6223

If I understod you correctly, you want to apply htmlentities.

Upvotes: 1

Related Questions