Solved

strip html tags except <b></b> and <br /><br>

Posted on 2010-08-27
6
715 Views
Last Modified: 2013-12-13
Hello,

I would like to strip all tags except, <br>, <br /> and <b>.

Is this possible?

<?=$description?>
0
Comment
Question by:movieprodw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 33545168
You can try this:

description = ereg_replace("<[^>]*>", "", $description)
0
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 33545218
or a simpler version of regex:

$description = strip_tags($description);
0
 
LVL 1

Author Comment

by:movieprodw
ID: 33545255
I know that guys, please understand that I want to KEEP andy <br>, <br /> and <b></b>
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 24

Accepted Solution

by:
mankowitz earned 250 total points
ID: 33545360
strip_tags takes a second argument which is the list of tags not to strip. See http://us3.php.net/strip_tags

$description = strip_tags($description,"<b><br>");
0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 250 total points
ID: 33545362
In that case

strip_tags( $string_to_strip, "<b></b><br/><br>" );

see http://localhost/adummy/docs/ for more info, especially the second parameter.
0
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 33545448
sorry, I misred that question, yes, that exta arg will do it.
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question