HTML을 이스케이프 처리하여 렌더링을으로 렌더링하려면 값에 htmlentities()을 사용하십시오. 출력 할 때
이 작업을 수행 할 수 있습니다 위에
<?php
// perhaps in some loop
echo htmlentities($row['post_content']);
?>
또는 루프를 첫째, 당신은 (인 print_r가는 경우)는 :/
<?php
$data = [
['post_content' => '<div id="foo"></div>'],
['post_content' => '<div id="bar"></div>'],
];
array_walk($data, function(&$value, $key) {
$value['post_content'] = htmlentities($value['post_content']);
});
print_r($data);
결과 : https://3v4l.org/aD33U
Array
(
[0] => Array
(
[post_content] => <div id="foo"></div>
)
[1] => Array
(
[post_content] => <div id="bar"></div>
)
)
업데이트 (모든 HTML 태그를 제거)
<?php
$data = [
['post_content' => '<td><b> Lenovo </b></td>'],
['post_content' => '<td><b> Dell </b></td>'],
];
array_walk($data, function(&$value, $key) {
$value['post_content'] = trim(strip_tags($value['post_content']));
});
print_r($data);
결과 : 당신은 대체하지 않는 한 https://3v4l.org/D1lfp
Array
(
[0] => Array
(
[post_content] => Lenovo
)
[1] => Array
(
[post_content] => Dell
)
)
HTML은 항상 렌더링되는 그는'<'또는'>'기호로 괄호를 마크 업. anwers에 대한 –
감사 : 그래서 저장됩니다