View Full Version : Remove all html tags except <p> and <em>

03-01-2010, 10:19 AM
I've never quite figured out regular expressions. Does anyone know how to strips out all html except <p> and <em>?

03-01-2010, 10:32 AM
I’d rather convert them to something like BBCode run strip_tags() and undo the tag masking.

03-01-2010, 10:39 AM
The problem there is I'm trying to remove MS Word formatting at the same time.
Because there are styles in the paragraph tag e.g.:

<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none">

So I'm not sure how to strip out everything and leave <p>'s and <em>'s?

03-01-2010, 11:31 AM
That will match all p and em tags for you

03-01-2010, 12:58 PM
strip_tags( $html, '<p><em>' );

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum