- substr: documentation ( source)
- preg_match: documentation ( source)
- explode: documentation ( source)
- strrpos: documentation ( source)
- preg_replace: documentation ( source)
<?php
$source = 'some css';
$source = explode('<!-- DEFAULT -->',$source);
$return =(count($source)>1)?$source[1]:$source[0];
$ad_loop_regex = "/[\s\S]*\{%[\s]*for[\s]*ad[\s]*in[\s]*ads[\s]*%\}\s/";
$end_loop_regex = '/[\.\s\S]*\{%[\s\S]*endfor[\s\S]*%\}/';
if ($html==true&&preg_match($ad_loop_regex, $return)&&!$master) {
$return = preg_replace($ad_loop_regex,'',$return);
preg_match($end_loop_regex,$return,$temp_preg_arr);
if (count($temp_preg_arr)>0) {
$return = $temp_preg_arr[0];
$start_tag = strrpos($return,'{');
$return = substr($return,0,$start_tag);
}
}
echo $return;