Solved

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

Posted on 2010-08-27
6
680 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 28

Expert Comment

by:sammySeltzer
Comment Utility
You can try this:

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

Expert Comment

by:sammySeltzer
Comment Utility
or a simpler version of regex:

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

Author Comment

by:movieprodw
Comment Utility
I know that guys, please understand that I want to KEEP andy <br>, <br /> and <b></b>
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 24

Accepted Solution

by:
mankowitz earned 250 total points
Comment Utility
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
Comment Utility
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 28

Expert Comment

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

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now