WillyTheFish Posted August 4, 2010 Share Posted August 4, 2010 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 Quote Link to comment Share on other sites More sharing options...
simshaun Posted August 4, 2010 Share Posted August 4, 2010 Put simply, strip_tags() does not play nicely with Word. Quote Link to comment Share on other sites More sharing options...
WillyTheFish Posted August 4, 2010 Author Share Posted August 4, 2010 okay, so what are my options? Quote Link to comment Share on other sites More sharing options...
simshaun Posted August 4, 2010 Share Posted August 4, 2010 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. Quote Link to comment Share on other sites More sharing options...
sasa Posted August 4, 2010 Share Posted August 4, 2010 in string is nothing but tags and strip_tags() function strip it all Quote Link to comment Share on other sites More sharing options...
WillyTheFish Posted August 4, 2010 Author Share Posted August 4, 2010 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]); 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.