Suppose this is your HTML element.
$html = '<div id="container"> <h1 class="dl">Datainflow</h1> <div id="descr">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s when an unknown printer took a galley of type and scrambled it to make a type specimen book.</div> </div>';
Now If you want to remove element using class, then use the following code.
$html = preg_replace('#<h1 class="dl">(.*?)</h1>#', '', $html);
If you want to remove element using ID, then use the following code.
$html = preg_replace('#<div id="descr">(.*?)</div>#', '', $html);
Question and answer is powered by AnsPress.io