Jump to content

Recommended Posts

I want to be able to strip the MARGIN elements from the <P> tags.

Currently, I use strip tags to remove the <P> elements completely, but have found that this results in a poorer display of the clients data, since its ignoring paragraphs.

 

What I actually want to do is just ignore the MARGIN settings within the P tags.  Does anyone know how I can achieve this?

Link to comment
https://forums.phpfreaks.com/topic/70595-strip-margin-from-p-tags/
Share on other sites

The source text with the margin information can vary.

 

Its containted within a description field, which my customers provide in HTML format.

Here is one example.  But the margin parameters could be set to anything, and the margin info could appear anywhere in the string. So it needs to be removed from every occurence in the string wherever it is.

 

<P class=MsoNormal style=MARGIN: 0in 0in 0pt;

 

Any ideas?

 

 

 

 

What I think would solve the issue is to strip any occurences of class=".." and style=".." from within any <p> tags.  Since those  classes and styles can contain anything from my clients, can someone suggest a way I can achieve this?

It sounds quite tricky, you can probably do it using a few explodes or str_replaces but as I said, quite trick

 

How do the margin elements get in there ni the first place, maybe you should look at it that way. Kill it before it gets in and merged with your p tags

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.