|
 |
15년 전 |
//////////////////////////////////////////////////////////////////////////////
// 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;
?>
|
|
추천 : 866 |
추천
목록
|
|