"PHP 함수 highlight()"의 두 판 사이의 차이

5번째 줄: 5번째 줄:
function highlight($text, $searchtext, $color='yellow') {
function highlight($text, $searchtext, $color='yellow') {
     if($searchtext == '') return $text;
     if($searchtext == '') return $text;
     return preg_replace('#' . preg_quote($searchtext, '#') . '#iu',
     return preg_replace('#' . preg_quote($searchtext,'#') . '#iu',
         '<span style="background:'.$color.'">$0</span>', $text);
         '<span style="background:'.$color.'">$0</span>', $text);
}
}

2015년 8월 3일 (월) 13:56 판

PHP highlight 함수

1 소스 코드

function highlight($text, $searchtext, $color='yellow') {
    if($searchtext == '') return $text;
    return preg_replace('#' . preg_quote($searchtext,'#') . '#iu',
        '<span style="background:'.$color.'">$0</span>', $text);
}

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}