Jump to content

Why won't strip_tags() work on this string?


WillyTheFish

Recommended Posts

Hey guys!

 

I tried to use strip_tags() on this string, but the function will return a null-string for some reason?

Any idea why, and any suggestion how to solve this?

$string = '<Word.Bookmark.Start" w:name="a"/><w:p><w:pPr><w:jc w:val="center"/><w:rPr><w:sz w:val="16"/><w:sz-cs w:val="16"/></w:rPr></w:pPr><w:r><w:rPr><w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial"/><wx:font wx:val="Arial"/><w:b/><w:highlight w:val="light-gray"/></w:rPr><w:t>Engagerad</w:t></w:r><aml:annotation aml:id="0" w:type="Word.Bookmark.End>';

echo strip_tags($string); // returns nothing, nada...

 

thank you :)

Link to comment
https://forums.phpfreaks.com/topic/209792-why-wont-strip_tags-work-on-this-string/
Share on other sites

Honestly I don't know of any foolproof PHP-only solutions.  There are some regex's you could implement, but I'm not sure how well they work on a wide variety of docs.

 

Check out http://stackoverflow.com/questions/67964/what-is-the-best-free-way-to-clean-up-word-html and see if any of the resources mentioned there help you.

The String contains a value between the tags aswell "Engagerad", which got stipped aswell.

I solved this by using the following regex:

$regex_strip_tags = "/<[\/\!]*?[^<>]*?>/";
$result[1][] = preg_replace($regex_strip_tags,'',$snippets[0][$key]);

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.