//iframe 제거

 $STRING = preg_replace("!<iframe(.*?)<\/iframe>!is","",$STRING);
 

 //script 제거

 $STRING = preg_replace("!<script(.*?)<\/script>!is","",$STRING);
 

 //meta 제거

 $STRING = preg_replace("!<meta(.*?)>!is","",$STRING); 
 

 //style 태그 제거

 $STRING = preg_replace("!<style(.*?)<\/style>!is","",$STRING); 
 

 //&nbsp;를 공백으로 변환

 $STRING = str_replace("&nbsp;"," ",$STRING);
 

 //연속된 공백 1개로

 $STRING = preg_replace("/\s{2,}/"," ",$STRING);
 

 //태그안에 style= 속성 제거

 $STRING = preg_replace("/ style=([^\"\']+) /"," ",$STRING); // style=border:0... 따옴표가 없을때
 
$STRING = preg_replace("/ style=(\"|\')?([^\"\']+)(\"|\')?/","",$STRING); // style="border:0..." 따옴표 있을때
 

 //태그안의 width=, height= 속성 제거

 $STRING = preg_replace("/ width=(\"|\')?\d+(\"|\')?/","",$STRING);
 $STRING = preg_replace("/ height=(\"|\')?\d+(\"|\')?/","",$STRING);
 

 //img 태그 추출 src 추출

 preg_match("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i",$STRING,$RESULT);
 preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i",$STRING,$RESULT);

+ Recent posts