php에서 태그 안의 내용만 지우려고 하는데요.
정규식이용해서 preg_replace 함수를 사용하면 태그까지 같이 지워져버리네요;;
<td id="msg">~~</td> td안의 내용만 지우려고 하는데 어떻게 해야할까요??;;
댓글 5개
만두야닷컴
9년 전
http://sir.co.kr/qa/
9년 전
스크립트를 사용할수있다면... 스크립트를 쓰는것도 나쁘진않을듯...
$('#msg').html(''); 비워버려요 ㅋㅋㅋ
$('#msg').html(''); 비워버려요 ㅋㅋㅋ
9년 전
$('#msg').hide(); 지워버리세요 -_-;;;
9년 전
저도 스크립트를 사용해서 지워버리곤합니다 ㅋㅋㅋ $('#msg').html('');
9년 전
[code]
<?php
$line = '<td id="msg">test</td>';
$line = preg_replace_callback('|(\<.*?\>)(.*?)(\<\/.*?\>)|', create_function('$matches', 'return $matches[1].$matches[3];'), $line);
echo $line;
?>
[/code]
<?php
$line = '<td id="msg">test</td>';
$line = preg_replace_callback('|(\<.*?\>)(.*?)(\<\/.*?\>)|', create_function('$matches', 'return $matches[1].$matches[3];'), $line);
echo $line;
?>
[/code]
게시판 목록
개발자톡
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 1434 |
seoldi
|
10년 전 | 1239 | |
| 1433 |
|
10년 전 | 1436 | |
| 1432 | 10년 전 | 742 | ||
| 1431 |
leeleeleelee
|
10년 전 | 939 | |
| 1430 |
RinaP
|
10년 전 | 803 | |
| 1429 |
|
10년 전 | 1275 | |
| 1428 | 10년 전 | 1127 | ||
| 1427 |
senseme
|
10년 전 | 1413 | |
| 1426 |
|
10년 전 | 1902 | |
| 1425 |
leeleeleelee
|
10년 전 | 1597 | |
| 1424 | 10년 전 | 991 | ||
| 1423 | 10년 전 | 910 | ||
| 1422 |
울라라라우
|
10년 전 | 909 | |
| 1421 | 10년 전 | 923 | ||
| 1420 |
프로그램은어려워
|
10년 전 | 1262 | |
| 1419 |
senseme
|
10년 전 | 1216 | |
| 1418 | 10년 전 | 2127 | ||
| 1417 |
파랑새1597
|
10년 전 | 1233 | |
| 1416 |
파랑새1597
|
10년 전 | 1345 | |
| 1415 |
integrity7
|
10년 전 | 1434 | |
| 1414 | 10년 전 | 994 | ||
| 1413 |
blackkil
|
10년 전 | 1916 | |
| 1412 | 10년 전 | 814 | ||
| 1411 | 10년 전 | 1426 | ||
| 1410 |
멋진남자임
|
10년 전 | 1168 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기