I am trying to replace content inside particular div tags (id=”dd-header”) with a comment. Tried several methods, and regular expressions. This is my latest try:
$html = preg_replace('/(<div\sid=\"dd\-header\">)[^<]+(<\/div>)/i', '<!-- Comment -->', $html);
Couldn’t get it working. What am I doing wrong here?
NOTE: div tags further have multiple tags
Sample Code to Replace
<div id="dd-header">
<a id="logo-small" href="/" title="title"></a>
<a href="http://url/">Link 1</a> |
<a href="javascript: (function () {window.location = 'http://url=' + encodeURIComponent(window.location.href);})()">Link 2</a>
<!-- <a href="http://url">Image</a> | -->
| <a href="url">Link 3</a></div>
see http://codepad.org/GpYkteh4