Link to home
Start Free TrialLog in
Avatar of Fernanditos
Fernanditos

asked on

PHP function to clean string from HTML tags except url and strong tag.

Hi,

Does someone knows a php function to clean a php string from all tags except links and bold text?

Please help.
Thank you.
Avatar of DanMerk
DanMerk
Flag of United States of America image

You can use the trim command and pass it everything that should be trimmed via the second parameter.

http://php.net/manual/en/function.trim.php
Avatar of Fernanditos
Fernanditos

ASKER

Trim was not exactly the solution. I found strip_tags do it great.


<?php echo strip_tags($row_rsPage['body_pnas_en'], '<p><a><br><li><strong>'); ?>

Open in new window


htmlentities,htmlspecialchars

Open in new window

You're on firm ground with strip_tags() but please read the warnings on the man page.  See also this note:
http://us.php.net/manual/en/function.strip-tags.php#88991

Best regards, ~Ray
ASKER CERTIFIED SOLUTION
Avatar of kumaranmca
kumaranmca

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