About str_replace_once($needle,$replace,$haystack), how to replace only the content without replacing the alt and title tags in
The original code is as follows
Code 1:
<code>public function str_replace_once($needle,$replace,$haystack) { $pos = strpos($haystack, $needle); if ($pos === false) { return $haystack; } return substr_replace($haystack, $replace, $pos, strlen($needle)); } </code>
Please help me how can I replace only the text content when replacing characters, but not the alt and title characters in the image
My purpose is, there is an article $str, and then there is an array $arr=array("小草","小花","狗","Willow"); I want to include all the array contents in the article. Replace it with something like Xiaocaohuahua, which is equivalent to an internal link in the article, but when encountering
//does not operate
aaa//does not operate
aa
//Do not operateAbout str_replace_once($needle,$replace,$haystack), how to replace only the content without replacing the alt and title tags in
The original code is as follows
Code 1:
<code>public function str_replace_once($needle,$replace,$haystack) { $pos = strpos($haystack, $needle); if ($pos === false) { return $haystack; } return substr_replace($haystack, $replace, $pos, strlen($needle)); } </code>
Please help me how can I replace only the text content when replacing characters, but not the alt and title characters in the image
My purpose is, there is an article $str, and then there is an array $arr=array("小草","小花","狗","Willow"); I want to include all the array contents in the article. Replace it with something like Xiaocaohuahua, which is equivalent to an internal link in the article, but when encountering
//does not operate
aaa//does not operate
aa
//Do not operate
String replacement is no longer enough for you, please try regular expressions.
Or if you want to process tags, you can try those plug-ins for xml parsing