채택완료

최신글 제목에 특수문자 없애기

2017-08-24 (목) 09:05:32 2,670

Copy
<?php echo cut_str(strip_tags($list[$i]['subject']), 34,'…'); ?>
  

cut_str로 제목글자 자르기함수를 써놨는데 여기에 추가적으로 특수문자들은 안나오게 처리하려고합니다

!!!!!!!!!!!!!!!!!!!!!!

|

답변 3개

2017-08-24 (목) 09:23:35

Copy
<?php 				$business_title = $list[$i]['subject']; 				$business_title = str_replace(array("!","@","#","$","※"), "", $business_title); ?>				<?php echo cut_str(strip_tags($business_title), 34,'…'); ?>


이렇게 처리하니 잘되네요 대신 array 노가다를 좀..

Copy
function processText($text) {    $text = strip_tags($text);    $text = trim($text);    $text = htmlspecialchars($text);    return $text;}

윗분 답변과 더불어 이걸 쓰시면 좋겠네요

답변을 작성하려면 로그인이 필요합니다.