i am working on project, in main page we display users detail and every user update its detail him self and we also allow HTML tags in detail.
but the problem what i am facing is, if person add some HTML detail like
<p><span style="color:#4c4c4c;font-family:Verdana;">Graphic Designer. Contact ***** .</span></p>
but on index page we display few character of detail and it comes to main page like this
<p><span style="color:#4c4c4c;font-family:Verda
this disturb all structure of main page.
i have tried PHP function
strip_tags
this did’t work for me and i also write my own function to strip these tags on main page
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',
'@</?((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(
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',"$0", "$0", "$0", "$0", "$0", "$0","$0", "$0",), $text );
return strip_tags( $text);
}
this also did’t work.
what i need is: to strip all html tags for proper display on main page.
Thanks
strip_tags()is built into PHPHTML Purifier is even more robust solution