tinmanbf Posted February 19, 2011 Share Posted February 19, 2011 Hi All, Hope you can help, I'm having problems with the strip_tags code, I'm having problems getting it to work with certain tags, the code below shows my issue: $print_description = <span style="color: #ff99cc; font-size: large">4 x BLUE handmade clay feet</span> $print_description = strip_tags($print_description); //remove html because of danger of broken tags I've cut down the code to show the problem. So I want to strip the Span tags; the problem I am having is as soon as you have a style attribute with more than one attribute and you use a ; symbol strip_tag will strip the entire content of the <span>AND ALL THE TEXT IN THE MIDDLE</span>. I want to just be left with '4 x BLUE handmade clay feet' If I take the ; out and just have one style it works fine. I am using tiny_MCE so don't have the option not to use what it makes me use. I've searched the net and have tried a few things to make it work but now I'm at a loss. Any help would be gratefully received. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted February 19, 2011 Share Posted February 19, 2011 Well I tried the exact code you gave us and it gave me the result you wanted...are you sure something else is not causing the problem? Regards, PaulRyan. Quote Link to comment Share on other sites More sharing options...
tinmanbf Posted February 19, 2011 Author Share Posted February 19, 2011 if i delete one of the attributes so I just have: $print_description = <span style="color: #ff99cc">4 x BLUE handmade clay feet</span> $print_description = strip_tags($print_description); //remove html because of danger of broken tags then it works fine but as soon as I add the second attribute ... ; font-size: large .... it stops working? Here is some more of the code, maybe it's not that part that is causing the issue: if ($max_description != 0) { $description = stringsplit($print_description, $max_description); // so lets only show the first xx characters if (strlen($print_description) != strlen($description[0])) { $description[0] = $description[0] . ".."; } $print_description = $description[0]; } $print_description = strip_tags($print_description); //remove html because of danger of broken tags I sorten the output so could the ; be effecting this part of the script? Quote Link to comment Share on other sites More sharing options...
tinmanbf Posted February 19, 2011 Author Share Posted February 19, 2011 Just solved this myself, after pasting the other bit of the code it came to me; I was limiting the letters before removing the tags, so with larger tags I would end up with no text because I would have just captured the tags and then removed them! Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted February 19, 2011 Share Posted February 19, 2011 Well spotted Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.