djuro djuric
djuro djuric

Reputation: 39

Remove certain html tags from text based content

I'm using CKE text editor http://ckeditor.com on my web site.

When user create content using this text editor, text may have paragraphs, bullet lists, headers with different sizes etc... and all content is stored in mysql database as HTML format...So, when text is displayed from database, let say on home page as a featured article, it is displayed in same form as user stored it to db, so it causes aesthetics problems I want to know the best way to remove html tags from text string with PHP or Javacript and leave just text, because I dont wanna manualy type all possible html tags with str_replace() function. Thanks in advance

Upvotes: 0

Views: 65

Answers (1)

mfisher91
mfisher91

Reputation: 807

You're after PHP's strip_tags function. This removes both HTML and PHP tags from a string. Reference page: http://php.net/manual/en/function.strip-tags.php

Example:

$text = "<p>My string</p>";
echo strip_tags($text); //This would print "My string"

Upvotes: 1

Related Questions