$str = '
<p>text</p>
<div class="bad">dsfdag</div>
<p>TEXT</p>
<div class="entry">
<div class="uptl">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<p>test</p>
<a href="#">link</a>
<p>test</p>
</div>
<p>test1</p>
</div>
<p>test3</p>
<p>test4</p>';
$str = '
<p>text</p>
<div class="entry">
<div class="uptl"></div>
<p></p>
</div>';'
<div class="entry">
<div class="uptl"></div>
<p></p>
</div>
function delete_div($inside){
while(preg_match('/(<div[^>]*>)(.*?)(<\/div>)/is', $inside) == 1){
$inside = preg_replace('/(<div[^>]*>)(.*?)(<\/div>)/s', '', $inside);
}
return $inside;
}
function get_result($url){
$ch = curl_init();
$options = array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FOLLOWLOCATION => TRUE,
CURLOPT_HEADER => TRUE,
CURLOPT_URL => $url,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 120,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 YaBrowser/19.3.1.828 Yowser/2.5 Safari/537.36");
curl_setopt_array($ch, $options);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}