Home  >  Article  >  php教程  >  PHP搜索关键词描红函数 十分不错的,备份!

PHP搜索关键词描红函数 十分不错的,备份!

WBOY
WBOYOriginal
2016-06-06 19:49:411419browse

2012-12-23 点击看最新版本:http://blog.csdn.net/default7/article/details/8373293 ——————————————————————————————————————————————— PHP搜索关键词描红函数: function SearchReplaceKw($string,$sokw=

2012-12-23 点击看最新版本:http://blog.csdn.net/default7/article/details/8373293

———————————————————————————————————————————————


PHP搜索关键词描红函数:


function SearchReplaceKw($string,$sokw=''){
  if(empty($sokw) || empty($string)) return $string;
  $badString = array(
  '~',  '!',  '@',  '#',  '$',  '%',  '^',  '&',  '*',  '(',  ')',  '-',  '+',  '[',  ']',
  ':',  ';',  '\'', '"',  '|',  '\\', ',',  '.',  '?',  '/',  '',
  );
  $sokw = str_replace($badString,' ',$sokw);
  $sokw = preg_replace('/\s+/','|',$sokw);
  return preg_replace("/($sokw)/",'\\1',$string);
  }


因为不能发布,所有我直接粘贴了。

截图:

PHP搜索关键词描红函数 十分不错的,备份!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn