Return to Snippet

Revision: 29295
at July 26, 2010 11:23 by laddy


Initial Code
function highlight($sString, $aWords) {
	if (!is_array ($aWords) || empty ($aWords) || !is_string ($sString)) {
		return false;
	}

	$sWords = implode ('|', $aWords);
	return preg_replace ('@\b('.$sWords.')\b@si', '<strong style="background-color:yellow">$1</strong>', $sString);
}

Initial URL


Initial Description
キーワードをハイライトするようにHTMLでおきかえる。

Initial Title
キーワードのハイライト

Initial Tags


Initial Language
PHP