0
현재 작업중인 사이트에서 다음 기능을 사용하고 있습니다."trim words"기능에서 HTML 태그를 제거하십시오.
function trim_text($input, $length) {
// If the text is already shorter than the max length, then just return unedited text.
if (strlen($input) <= $length) {
return $input;
}
// Find the last space (between words we're assuming) after the max length.
$last_space = strrpos(substr($input, 0, $length), ' ');
// Trim
$trimmed_text = substr($input, 0, $last_space);
// Add ellipsis.
$trimmed_text .= '...';
return $trimmed_text;
}
그러면 다음과 같습니다.
echo trim_text($variableContainingContent, 100);
변수의 처음 100 자 이내가 하이퍼 링크가 아닌 한 아무 문제없이 작동합니다.
이 기능을 반향하기 전에 다른 HTML을 제거 할 수있는 방법이 있습니까?
'strip_tags()'어쩌면 ... – AbraCadaver
http://php.net/strip_tags – philtune