1
I preg_replace이다REGEX 변수를 htmlentities로 바꾸시겠습니까?
"<div style="font-style:italic;margin:8px 6px">$2</div>"
의 교체로 다음과 같은 코드가 $ 약 2를 htmlentities()를 포장 할 수있는 방법이 있나요이?
I preg_replace이다REGEX 변수를 htmlentities로 바꾸시겠습니까?
"<div style="font-style:italic;margin:8px 6px">$2</div>"
의 교체로 다음과 같은 코드가 $ 약 2를 htmlentities()를 포장 할 수있는 방법이 있나요이?
당신은 preg_replace_callback()
를 사용할 수 있습니다
function replace($matches) {
return '<div style="font-style:italic;margin:8px 6px">'
. htmlentities($matches[2]) . '</div>';
}
preg_replace_callback('/pattern/', 'replace', $string);
감사합니다. 나는 그 편리한 작은 기능에 대해 몰랐다. :) – Justin
당신의 따옴표를 두 번 확인, 구문 강조 뭔가를 잘 작성하지 제안합니다. – elclanrs