티스토리 뷰

참조 : http://blog.naver.com/OpenMagazineViewer.nhn?blogId=hcege&logNo=90111939736&categoryNo=0&parentCategoryNo=0&viewDate=

// iframe 제거
$str = preg_replace("!<iframe(.*?)</iframe>!is","",$str);

// script 제거
$str = preg_replace("!<script(.*?)</script>!is","",$str);

// meta 제거
$str = preg_replace("!<meta(.*?)>!is","",$str);

// style 태그 제거
$str = preg_replace("!<style(.*?)</style>!is","",$str);

//   를 공백으로 변환
$str = str_replace(" "," ",$str);

// 연속된 공백 1개로
$str = preg_replace("/s{2,}/"," ",$str);

// 태그안에 style= 속성 제거
$str = preg_replace("/ style=([^&#92;"&#92;'+) /","",$str);   // style-border:0... 따옴표가 없을때
$str = preg_replace("/ style=(&#92;"&#92;')?(^&#92;"&#92;'+)(&#92;"&#92;')?/",""$str);   // style="border:0..." 따옴표가 있을때

// 태그안의 width= / height= 속성제거
$str = preg_replace("/ width=(&#92;"&#92;')?&#92;d+(&#92;"&#92;')?/","",$str);
$str = preg_replace("/ height=(&#92;"&#92;')?&#92;d+(&#92;"&#92;')?/","",$str);

// img 태그 추출 src 추출
preg_match("/ <img[^>*src=[&#92;"']?([^>&#92;"']+)[&#92;"']?[^>*>/i",$str,$result);
preg_match_all("/ <img[^>*src=[&#92;"']?([^>&#92;"']+)[&#92;"']?[^>*>/i",$str,$result); 

Total
Today
Yesterday
최근에 올라온 글
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31