/**
* 文章详情匹配一次关键字内链
*
* @param $content string 文章内容
* @param $arr array 关键字数组
* @param $url string 内链url
* @param $suffix string url后缀
*/
function articleInner($content, $arr, $url, $suffix='.html'){
$regular = '<a .*>.*<\/a>|<img .*>|<iframe .*>.*<\/iframe>';
$chunkeds = preg_split("/($regular)/Ui", $content, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$tagArr = array();
foreach ($chunkeds as $k => $val) {
$bool = preg_match("/($regular)/Ui", $val);
if(!$bool){
foreach ($arr as $key => $value) {
if(($position = strpos($val,$value['name']))!==false && !in_array($value['name'], $tagArr)){
$leng = strlen($value['name']);
$replIntro = "<a h
php文章内容内链功能,相同关键字只内链一次
最新推荐文章于 2021-04-13 16:37:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)