2011-10-22 4 views
3

태그를 제외한 모든 태그를 (htmlentities) 인코딩하거나 사용하지 않으려합니다.<a>을 제외한 모든 태그 사용 안 함

어떻게하면됩니까?

preg_replace('/&lt;(\/?a(?:|\s[\S\s]+?))&gt;/i', '<$1>', $string); 

가 다른 태그를 제거하려면 다음을 사용 :

+0

[스트립 모든 HTML 태그의 중복 가능성, except allowed] (http://stackoverflow.com/questions/6247035/stest-all-html-tags-except-allowed) – JJJ

+0

@Juhana OP는 모든 HTML 태그를 인코딩해야합니다 (허용되지 않는 경우 제외). – xdazz

답변