- preg_replace: documentation ( source)
<?php
function _remove_between($tag,$subject) {
return preg_replace("/".$tag.".+?".$tag."/i", "", $subject);
}
$html = '{% load ad_tags %}{% load smart_if %}<div id="wrapper">{% set_list 1 2 as sub_0_range %}{% set_list 3 4 5 6 7 8 9 as sub_1_range %}{% for ad in ads %}{% if forloop.counter in sub_0_range %}<div class="sub_0">{% if forloop.counter == sub_0_range.0 %}<div id="header">
<h1>Great Auto Insurance Rates!</h1>
<h2>Click on a handful of the companies below to get your rates.</h2>
</div><div id="featured-listings">
<p class="listing-grp-title"><strong>Featured Insurance Providers</strong></p>{% endif %} <!--WRAPPERSTART--><div id="header">
<h1>Great Auto Insurance Rates!</h1>
<h2>Click on a handful of the companies below to get your rates.</h2>
</div><div id="featured-listings">
<p class="listing-grp-title"><strong>Featured Insurance Providers</strong></p><!--WRAPPERSTART-->
<div class="featured-wrap">
<div class="star"><img src="http://dev-15-php.datalot.com/images/ad_temp/star.png" alt="star" /></div>
<div class="container">
<div class="logo">
<a href=""><img src="http://dev-15-php.datalot.com/images/ad_temp/feature-logo2.png" alt="" /></a>
</div>
<div class="copy">
<p class="headline"><a href="">{{ad.headline|safe}}</a></p>
{{ad.body|safe}}
</div>
<div class="btn"><a href=""><img src="http://dev-15-php.datalot.com/images/ad_temp/button_top3.gif" alt="Free Quote" /></a></div>
<div class="clear"></div>
</div>
</div>
<div class="clear"></div>
{% if forloop.counter == sub_0_range|last or forloop.last %}</div>{% endif %}</div>{% else %}{% if forloop.counter in sub_1_range %}<div class="sub_1">{% if forloop.counter == sub_1_range.0 %}<div id="top-listings">{% endif %}
<div class="top-wrap">
<div><p class="number">{{forloop.counter|add:-2}}</p></div>
<div class="container">
<div class="logo">
<a href=""><img class="featured-logo" src="http://dev-15-php.datalot.com/images/ad_temp/feature-logo2.png" alt="" /></a>
</div>
<div class="copy">
<p class="headline"><a href="">{{ad.headline|safe}}</a></p>
{{ad.body|safe}}
</div>
<div class="btn"><a href=""><img src="http://dev-15-php.datalot.com/images/ad_temp/button_top3.gif" alt="Free Quote" /></a></div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
{% if forloop.counter == sub_1_range|last or forloop.last %}</div></div>{% endif %}</div>{% else %}<!-- DEFAULT --><!-- DEFAULT -->{% endif %}{% endif %}{% endfor %}</div>';
$html = _remove_between('<!--WRAPPEREND-->',$html);
echo $html;