//替换一次
function str_replace_once($needle, $replace, $haystack) {
$pos = strpos($haystack, $needle);
if ($pos === false) {
// Nothing found
return $haystack;
}
return substr_replace($haystack, $replace, $pos, strlen($needle));
}
$body = $this->str_replace_once($tagname,'<a href="'.$url.'" title="'.$tagname.'" style=" font-weight:bold">'.$tagname.'</a>',$body);
str_replace替换一次Demo
最新推荐文章于 2021-08-24 09:46:18 发布