Im trying to implement functionality wich will replace only specific word between <p>
tags
For example:
<p>this is word i need to replace</p>
In this case "word" will be replaced with some other word (but only inside <p>
tags)
Currently im using:
preg_replace("/\b$keyword\b/", $replaceWord, $content, 2);
$content - contains all html
$keyword - word wich need to be replaced in that content
$replaceWord - word wich we want to use instead $keyword
But this logic above will replace also keywords wich are not inside paragraph. How its possible to update this regex, so it replaces only words inside paragraphs?
NOTE: Please make a note that i cannot use Simple HTML DOM Parser