PHP to the HTML text keyword hyperlink, ask the big God pointing.
Add hyperlinks to keywords we usually replace them with regular.
But the problem is that the ALT keyword inside the image is replaced with a link. and the text that originally had hyperlinks was also replaced.
such as the use of computers, the keyword has a computer word, this should not be replaced, the results have been replaced.
For example, the keyword has a computer word, this should not be replaced, the result of the computer is also replaced by the word is a hyperlink content.
Computers can improve productivity
Note: You want the word "computer" to automatically add hyperlinks, such as to become
Computers can improve productivity
Computer Use Note: Do not want the word "computer" plus hyperlinks
Note: Do not want to add hyperlinks to the computer word
Ask the big God's weapon, give a train of thought also line.
------Solution--------------------
Give me a clue.
$s =<<< TXT
Computers can improve productivity
Note: You want the word "computer" to automatically add hyperlinks, such as to becomeComputers can improve productivity
Computer Use Note: Do not want the word "computer" plus hyperlinks
Note: Do not want to add hyperlinks to the computer word
TXT;
$p = '/(?: ^
------Solution--------------------
>). *?) Computer ([^<]*-?:< (?! \/A)
------Solution--------------------
$))/is ';
Echo preg_replace ($p, ' $ ' "$ $", $s);
"Computer" can improve productivity
Note: You want the word "computer" to automatically add hyperlinks, such as to become
Computers can improve productivity
The use of the computer note: Do not want "" "Computer" "Two words plus hyperlinks
Note: Do not want the word "computer" plus hyperlinks