内容过滤-但允许iframe嵌入内容


Content filtering - but allow iframes for embeded content

我使用下面的正则表达式来过滤内容,但是我需要用户能够在所见即所得的编辑器中添加iframe,目前它正在剥离那些,我怎么能编辑它来保持它的所有功能,但阻止它剥离iframe ?谢谢你

$content = preg_replace("%<[a-z]{1,6}[^>]*>'s*</[a-z]{1,6}>%ims","",$content);

使用这个正则表达式:

$content = preg_replace("%(</?(?!iframe)[a-z0-6]{0,10}[^>]>)%im", "", $content);

或更好:

strip_tags($content, "<iframe>");