Solved

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

Posted on 2010-08-27
6
708 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I update select listbox after search 2 51
Bootstrap - BootBox - PHP - MYSQL - Response Trigger 6 62
Insert PHP into HTML page. 7 52
PHP, Curl and XML 13 18
This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 look for a specific file type in a local or remote server directory using PHP.

752 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