Php adds hyperlinks to html text keywords. We usually use regular expressions to replace a keyword with a hyperlink.
However, the problem arises. the keywords in alt in the image are replaced with links. Text with hyperlinks is also replaced.
For example, if a computer is used and the keyword is "computer", this item should not have been replaced, and the result is also replaced.
For example, if the keyword is a computer word, this word should not have been replaced. as a result, the computer word is also replaced with a hyperlink.
Computers can improve work efficiency
Note: to automatically add a hyperlink to the word "computer", such
Computers can improve work efficiency
Note: You do not want to add a hyperlink to your computer.
Note: You do not want to add a hyperlink to your computer.
Please give me some advice.
Reply to discussion (solution)
Give a thought
$ S = <TXTComputers can improve work efficiency
Note: to automatically add a hyperlink to the word "computer", suchComputers can improve work efficiency
Note: do not want "computer" text plus hyperlink note: do not want computer text plus hyperlink TXT; $ p = '/((? : ^ |> ).*?) (Computer) ([^ <] * (? : <(?! \/A) | $)/is '; echo preg_replace ($ p,' $1 [$2] $ 3', $ s );
[Computer] can improve work efficiency
Note: to automatically add a hyperlink to the word "computer", such
Computers can improve work efficiency
Note: You do not want to add a hyperlink to "computer ".
Note: You do not want to add a hyperlink to the [computer ].