Solved

how to clean up unneccessary html tags

Posted on 2009-04-06
3
161 Views
Last Modified: 2012-05-06
I am using WYSIWYG ( tiny_mce) in my site.. i need to give privilege to users to use some html tags like <p> but if they paste unnecessary tags like <span style="font-weight: bold;"> which can not be estimated before hence str_replace() is not sufficient .

i think there can be a way like i select a portion from "<span"  to ... very next ">" and remove this from the content ?
0
Comment
Question by:amitbravo
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 24076262
you can use a regular expression to strip out those things like:

$str = preg_replace("/\\<span[^>]+\\>/", '<span>', $str);

Open in new window

0
 

Author Comment

by:amitbravo
ID: 24084426
awesome ! it works .. could we use this tech. somehow to add rel="no follow" in <a href=.. tags .. do not repeat "no follow" if already added
0
 
LVL 48

Expert Comment

by:hernst42
ID: 24086090
no thats AFAIK not possible with a regular expression or that regular expresion if far beyond my knowledge.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from 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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

776 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