[thelist] [PHP] Ignoring an IMG tag within a string

Tim Burgan email at timburgan.com
Mon Oct 25 01:51:16 CDT 2004

Thanks for your time, I'll certainly check all the regular expression
stuff out - it's something I'm gonna need to know.

I just rescanned the PHP manual and found the *strip_tags* function, and
it's really easy to use:

<tip type="Keep only certain HTML tags within a string (and discard the others) using PHP">

    To keep only certain HTML tags that are contained in a string and ignore all others, 
use PHP's strip_tags function.

        strip_tags($string, "allowable tags here");

    Example Code:
           $string = '<img src="#"/><p>Phasellus interdum orci ac tortor.</p>';
           echo strip_tags($string, "<p>");

    Example Output:
        <p>Phasellus interdum orci ac tortor.</p>

    Easy as that.



Tim Burgan.
Website Development & Graphic Design

E <email at timburgan.com>
W <www.timburgan.com>

More information about the thelist mailing list