Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-08-27
6
Medium Priority
?
739 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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 24

Accepted Solution

by:
mankowitz earned 1000 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 1000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

916 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