Link to home
Start Free TrialLog in
Avatar of Dennie
Dennie

asked on

php strip empty html tags

Hi Experts!

With Curl my script receives HTML code from a website. From that source I would like to strip all empty tags such as <p> </p>

Somehow I can't seem to remove them, I think it has something to do with character settings or something. This is what I've tried:

$html = preg_replace('/<[^\/>]*>([\s]?)*<\/[^>]*>/','' , $html);
$html = preg_replace('%<p></p>%','' , $html);
$html = preg_replace('%<p> </p>%','' , $html);
$html = str_replace('<p> </p>','',$html);

Any suggestions?
Avatar of sshah254
sshah254

I think the syntax should be

$html = preg_replace('\<p>\<\p>','' , $html);

to remove <p></p>

Ss
Avatar of Dennie

ASKER

nope not working
ASKER CERTIFIED SOLUTION
Avatar of Dennie
Dennie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aaron Tomosky
I think you have to escape every less than and greater than  and slash.
\<p\>\<\/p\>
Avatar of Dennie

ASKER

Solved the problem :)