I need a very little help to find the content inside certain and tags.
Example:
$string = '<a href="dummyurl">TEXT</a><span>Other Text</span>';
I'd like to find 'TEXT' and replace it with some other value. Obviuosly the content of 'href' and 'TEXT' is dynamically generated.
http://php.net/manual/en/class.domdocument.php
If you're sure there's no
>
character in the start tag (except for the obvious 1):Consider learning the DOM, which will enable you to work with both HTML and XML documents and answer questions like this in a generic manner. There is some learning curve, and it will be slower than fine-tuned local regexes, but it'll be more robust as well as applicable to nearly everything that is an HTML or XML document.
PHP has a whole big section on using the DOM in PHP within the manual.
Reference: phppro.org's Get Link Text