Page 1 of 1
Striping HTML and PHP tags from a $str
Posted: Fri May 31, 2002 3:19 pm
by mykg4orce
How do i do it...
lets say i have this:
Code: Select all
<?php
$str = "<i><b>Some Text Here</b></i>"
//I want it to return:
echo $str
//Some Text Here
?>
thanks in advance!!!!
Posted: Fri May 31, 2002 3:31 pm
by hob_goblin
Posted: Fri May 31, 2002 7:36 pm
by mykg4orce
but i have tried it and it doesn't work.
Code: Select all
<?php
$string = "<b>MY STRING</b>";
$string = strip_tags($string, '<b></b>');
echo $string;
//this returns: <b>MY STRING</b> when i view source in my brower.
//thats not what i thought it would do, i thought it would just remove what i tell it to in the arguement.
//The reason i want to remove any HTML tags is so that when i
//am using a script (Send To Friend) to send this string i
//dont want the HMTL tags included in the email msg.
//Argh!!!!!
?>
Posted: Fri May 31, 2002 7:40 pm
by hob_goblin
the second argument is the ALLOWED tags
Posted: Fri May 31, 2002 7:50 pm
by mykg4orce
what do you mean????
Posted: Fri May 31, 2002 7:54 pm
by hob_goblin
$string = "<b><u>Hi</u></b>";
$string_s = striptags($string, "<b>");
echo "$string_s";
would return
<b>Hi</b>
because the second paramater is the allowed tags, not the ones you want to strip, if you want to strip all tags, dont put a second paramater in, but if you want to exempt certain tags, put them there
if your trying to do this for security reasons; read the comments at:
http://www.php.net/manual/en/function.strip-tags.php
because some of them have very good points
Posted: Fri May 31, 2002 7:58 pm
by mykg4orce
ohhhh wow!!!! what a dufus I am

thanks!! man....