Solved

how to clean up unneccessary html tags

Posted on 2009-04-06
3
159 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 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

16 Experts available now in Live!

Get 1:1 Help Now