Skip to content Skip to sidebar Skip to footer

Using Preg_replace To Remove Html Tag

Here is some part of html in my page.
I want to remove the wpn_ad_

Solution 1:

It is very simple just the code you would like to remove with a non-greedy

$html = '
<div id="video-ad">
   <div id="wpn_ad_square">my example content</div>
</div>
';

echo preg_replace('/\<div id=\"wpn_ad_square\"\>(.*?)\<\/div\>/', '', $html);

Post a Comment for "Using Preg_replace To Remove Html Tag"