Solarpitch Posted November 15, 2007 Share Posted November 15, 2007 Hey Guys, I am here trying loads of different strip tags functions to format the text from the database the way I want, but it doesnt seem to be working. If you look at the below example. The bottom images shows how the text is currently been pulled and displayed from the database. I am looking to just format it as normal text when its been displayed in the result. If anyone can point me to a function that works, that would be great Link to comment https://forums.phpfreaks.com/topic/77474-php-strip_tags/ Share on other sites More sharing options...
rajivgonsalves Posted November 15, 2007 Share Posted November 15, 2007 whats your code if you already using the string_tags function it should strip all the html tags out Link to comment https://forums.phpfreaks.com/topic/77474-php-strip_tags/#findComment-392195 Share on other sites More sharing options...
Solarpitch Posted November 15, 2007 Author Share Posted November 15, 2007 Hi, Here's the code I am using at the min. I need to format the font the same size also but I take it removing any style tags should do this... function strip_html_tags( $text ) { $text = preg_replace( array( // Remove invisible content '@<head[^>]*?>.*?</head>@siu', '@<style[^>]*?>.*?</style>@siu', '@<script[^>]*?.*?</script>@siu', '@<object[^>]*?.*?</object>@siu', '@<embed[^>]*?.*?</embed>@siu', '@<applet[^>]*?.*?</applet>@siu', '@<noframes[^>]*?.*?</noframes>@siu', '@<noscript[^>]*?.*?</noscript>@siu', '@<noembed[^>]*?.*?</noembed>@siu', // Add line breaks before and after blocks '@</?((address)|(blockquote)|(center)|(del))@iu', '@</?((div)|(h[1-9])|(ins)|(isindex)|(p)|(pre))@iu', '@</?((dir)|(dl)|(dt)|(dd)|(li)|(menu)|(ol)|(ul))@iu', '@</?((table)|(th)|(td)|(caption))@iu', '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu', '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu', '@</?((frameset)|(frame)|(iframe))@iu', ), array( ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", ), $text ); return strip_tags( $text ); } Ive also tried this from the PHP manual.. [code] $text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>'; echo strip_tags($text); echo "\n"; // Allow <p> and <a> echo strip_tags($text, '<p><a>'); [/code] Link to comment https://forums.phpfreaks.com/topic/77474-php-strip_tags/#findComment-392198 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.