2015-10-30 2 views
0

У меня есть HTML строки и я хочу, чтобы удалить его ...Удалить элементы с preg_replace

$html = '<h2 class="post-title entry-title">Some Title</h2>'; 

$removeit = preg_replace('#<h2 class="post-title entry-title">(.*?)</h2>#', '', $html); 

Почему я не могу удалить его? в другом случае, если я буду использовать код ниже, я могу удалить div как

$html = '<div style="width:300px; height:120px; background-color:#000;">Some Title</div>'; 

$removeit = preg_replace('#<div style="width:300px; height:120px; background-color:#000;">(.*?)</div>#', '', $html); 

ответ