In order to optimize the chain, we need to add content to the key link, that content if you add links, how to add it?
Method One: Manually edit add
Method Two: The use of the program in the output content implementation, without affecting the background content of the edit.
Here's how PHP automatically adds links to article content and examples:
Keylinks Function Method:
Parameter one: the content to be processed
Parameter two: Replacement times
Return Result: Processed content
Header ("Content-type:text/html;charset=utf-8"); Set encoding
$linkdatas =array (
Array (' Front-End development ', ' http://blog.kgula.com '),
Array (' Front design ', ' http://blog.kgula.com '),
Array (' Web Front end ', ' http://blog.kgula.com '),
Array (' Front-End blog ', ' http://blog.kgula.com '),
);
echo "replace before <br/>";
echo $str = ' Web front-end development-focus on site front-end design and Web user experience. Front-End development, focus on the Web front-end development, focus on the Web user experience, focus on the latest and best front-end design resources and front-end development Technology professional front-end blog ';
echo "<br/> replace <br/>";
echo $str =keylinks ($STR, 2);
/**
* Associated keyword Replacement
* @param txt $string original string
* @param replacenum $int replacement times
* @return String returns strings
*/
function Keylinks ($txt, $replacenum = ' ") {
Global $linkdatas;
if ($linkdatas) {
$word = $replacement = Array ();
foreach ($linkdatas as $v) {
$word 1[] = '/(?! (<a.*?)) ' . Preg_quote ($v [0], '/'). '(?!. *</a>)/s ';
$word 2[] = $v [0];
$replacement [] = ' <a href= '. $v [1]. ' "target=" _blank "class=" Keylink ">". $v [0]. ' </a> ';
}
if ($replacenum!= ') {
$txt = Preg_replace ($word 1, $replacement, $txt, $replacenum);
} else {
$txt = Str_replace ($word 2, $replacement, $txt);
}
}
return $txt;
}