When I add an article, I need to automatically generate anchor text, keyword to match the content of the article, will match to the IMG alt and title value, the picture will appear abnormal.
Dear God, help me solve it! Thanks, man.
The original wanted is
这些文字加链接
Error content:
My code is written like this:
/** * 多关键词替换,每个替换一次 * @param Mixed $search 查找目标值 * @param Mixed $replace 替换值 * @param Mixed $subject 执行替换的字符串/数组 * @param Int $limit 允许替换的次数,默认为-1,不限次数 * @return Mixed */function str_replace_limit($search, $replace, $subject, $limit=-1){ if(is_array($search)){ foreach($search as $k=>$v){ $search[$k] = '`'. preg_quote($search[$k], '`'). '`'; } }else{ $search = '`'. preg_quote($search, '`'). '`'; } return preg_replace($search, $replace, $subject, $limit);}foreach ($keylink as $k){ $keyArray[] = $k->word; $url = 'url.'" style="color:red;font-size:1.2em;">'.$k->word.''; $replacement[] = $url;}
Reply content:
When I add an article, I need to automatically generate anchor text, keyword to match the content of the article, will match to the IMG alt and title value, the picture will appear abnormal.
Dear God, help me solve it! Thanks, man.
The original wanted is
这些文字加链接
Error content:
My code is written like this:
/** * 多关键词替换,每个替换一次 * @param Mixed $search 查找目标值 * @param Mixed $replace 替换值 * @param Mixed $subject 执行替换的字符串/数组 * @param Int $limit 允许替换的次数,默认为-1,不限次数 * @return Mixed */function str_replace_limit($search, $replace, $subject, $limit=-1){ if(is_array($search)){ foreach($search as $k=>$v){ $search[$k] = '`'. preg_quote($search[$k], '`'). '`'; } }else{ $search = '`'. preg_quote($search, '`'). '`'; } return preg_replace($search, $replace, $subject, $limit);}foreach ($keylink as $k){ $keyArray[] = $k->word; $url = 'url.'" style="color:red;font-size:1.2em;">'.$k->word.''; $replacement[] = $url;}
Can look at the code is not