PHP code for link with text
maybe try with php DOMDocument rather than regex. I don’t think all DOMDocument methods will work with just an html fragment and not a complete document, but for your needs it may be enough: <?php $dom= new DOMDocument(); $html=”<p>Some html with a <a href=”http://foo.com/”>link</a>. Some more text and <a href=”http://bar.com/”>another</a> link.</p>”; $dom->loadHTML( $html ); $dom->preserveWhiteSpace … Read more