Jump to content

strip_tags issue when stripping <Span style> tag


tinmanbf

Recommended Posts

 

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.

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.