1 PHP[ | ]
PHP
Copy
function remove_html_comments($html) {
return preg_replace('/<!--(.|\s)*?-->/', '', $html);
}
$str1 = "Hello<!-- bye -->World";
$str2 = "<link rel='stylesheet' href='a.css'>
<!-- <link rel='stylesheet' href='b.css'> -->
<link rel='stylesheet' href='c.css'>";
echo remove_html_comments($str1) . PHP_EOL;
# HelloWorld
echo remove_html_comments($str2) . PHP_EOL;
# <link rel='stylesheet' href='a.css'>
#
# <link rel='stylesheet' href='c.css'>
2 같이 보기[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.
PHP 파일 다운로드 구현 2 (한글 파일명 지원) ― …PHP에서 오라클 DB 사용 ― YoWuPHP 파일 업로드 구현 ― 일리단사오육칠PHP 파일 업로드 구현 ― JmnotePHP 파일 다운로드 구현 2 (한글 파일명 지원) ― AnmkstLib my.php ― 신정섭Lib my.php ― Jmnote로또번호 생성 ―Pinkcrimson