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 Link to comment https://forums.phpfreaks.com/topic/209792-why-wont-strip_tags-work-on-this-string/ 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. Link to comment https://forums.phpfreaks.com/topic/209792-why-wont-strip_tags-work-on-this-string/#findComment-1095127 Share on other sites More sharing options...
WillyTheFish Posted August 4, 2010 Author Share Posted August 4, 2010 okay, so what are my options? Link to comment https://forums.phpfreaks.com/topic/209792-why-wont-strip_tags-work-on-this-string/#findComment-1095129 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. Link to comment https://forums.phpfreaks.com/topic/209792-why-wont-strip_tags-work-on-this-string/#findComment-1095132 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 Link to comment https://forums.phpfreaks.com/topic/209792-why-wont-strip_tags-work-on-this-string/#findComment-1095194 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]); Link to comment https://forums.phpfreaks.com/topic/209792-why-wont-strip_tags-work-on-this-string/#findComment-1095206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.