사이트 내 전체검색
PHP
태그 제거.. strip_tags 보다 더 정확 strip_tags2
로빈아빠
https://cmd.kr/php/836 URL이 복사되었습니다.

본문

// 태그 제거.. strip_tags 보다 더 정확
function strip_tags21($data){
$search = array ("'<scRIPT[^>]*?>.*?'si",    // 자바 스크립트 제거
"'<[\/\!]*?[^<>]*?>'si",                    // HTML 태그 제거
"'<\!\-\-(.*)?\-\->'si",                        //주석제거
"'([\r\n])[\s]+'",                                
"'&(quot|#34);'i",                                // HTML 엔티티 치환
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'&#(\d+);'e");                    // php로 실행

$replace = array ("",
 "",
 "",
 "\\1",
 "\"",
 "&",
 "<",
 ">",
 " ",
 chr(161),
 chr(162),
 chr(163),
 chr(169),
 "chr(\\1)");

$data=preg_replace($search,$replace,$data);
$data=trim(strip_tags($data));
return $data;
}

댓글목록

등록된 댓글이 없습니다.

PHP
871 (3/18P)

Search

Copyright © Cmd 명령어 18.224.61.19