I am trying to remove an html tag with a specific "for" attribute but then also remove everything in between. I a have only been able to remove the tage itself but not what is in between even though there are some html tags in there as well. Below is the code that i am using:
This is the string i am working with:
$content = <<<EOD <label for="cl-gallery-el-slide4-elm_527" data-interactive="true" class="cl-gallery-el-nav-arrow-wrapper cl-gallery-el-nav-arrow-wrapper-prev">
<span class="cl-gallery-el-nav-arrow cl-gallery-el-nav-arrow-prev" data-interactive="true"></span>
</label>
EOD;
Below is the code for php
function strip_single_tag($str,$tag){
$str=preg_replace('/<'.$tag.'[^>]*>/i', '', $str);
$str=preg_replace('/<\/'.$tag.'>/i', '', $str);
return $str;
}
$content = strip_single_tag($content,'label for="cl-gallery-el-slide4-elm_527"');