//////////////////////////////////////////////////////////////////////////////
// FUNCTION: word_replace_css
//
// Description:
// 특정 단어를 골라내어 그 단어에 특수한 효과를 준다
// Param:
// $query - search word
// $string - target string
// $css - effect
// $ans - return value
//////////////////////////////////////////////////////////////////////////////
function word_replace_css($query, $string, $css, $ans) {
$data = spliti($query, $string);
$q_tmp = explode(" ", $query);
$ptr = $string;
$j=0;
for($i=0; $i<count($q_tmp); $i++) {
while(1) {
$ptr = stristr($ptr, $q_tmp[$i]);
if($ptr) {
$q[$j++] = substr($ptr, 0, strlen($q_tmp[$i]));
$ptr = substr($ptr, strlen($data[$j])+1);
} else break;
}
}
$ans = $data[0];
for($i=0; $i<$j; $i++) {
$ans .= "<span style='".$css."'>".$q[$i]."</span>".$data[$i+1];
}
}
/* 사용법 */
< ?
word_replace_css("abc", "abcdefghijklmn", "color:red;", &$ans);
echo $ans;
?>
'PHP∵SCRIPT' 카테고리의 다른 글
PHP file 처리 함수 (0) | 2014.04.15 |
---|---|
문자열 파일 처리함수 (0) | 2014.04.15 |
주요사이트들의 링크인기도 를 가져와서 보여주기 (0) | 2014.04.13 |
사이트 방문경로와 검색한 단어 알기 (0) | 2014.04.13 |
PHP를 이용한 이미지 사이즈 편집마스터 (0) | 2014.04.13 |
페이징- 다중 정렬 : 오름, 내림, 보통 (0) | 2014.04.13 |
멀티 파일 업로드 예제 (Flex2+PHP) (0) | 2014.04.12 |
플래시 파일 정보 얻어오는 소스(PHP) (0) | 2014.04.12 |
댓글