How do you find and replace a string in html page using the native PHP DOM Parser?
Example string to find: "the <a href='site.com'>company</a> has been growing for the past 5 months";
The parent is a full HTML page for example and the immediate predecessor of that string can be a <div>
or <p>
for example..
There is no id or class to that element. Is it still possible to find and manipulate it ?
There is nothing to identify the string or its immediate predecessor. Only the exact string, i.e. sequence of characters that the $search_string consists of.
Thanks!
EDIT:
$string_to_replace = "the <a href='site.com'>company</a> has been growing for the past 5 months";
$replacement_string = "<span class='someClass'>the <a href='site.com'>company</a> has been growing for the past 5 months";</span>