<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Blog &#187; strip_tags</title>
	<atom:link href="http://informationideas.com/news/tag/strip_tags/feed/" rel="self" type="application/rss+xml" />
	<link>http://informationideas.com/news</link>
	<description>Using technology to help your business</description>
	<lastBuildDate>Thu, 05 Aug 2010 22:53:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>php strip_tags problem</title>
		<link>http://informationideas.com/news/2008/05/19/php-strip_tags-problem/</link>
		<comments>http://informationideas.com/news/2008/05/19/php-strip_tags-problem/#comments</comments>
		<pubDate>Mon, 19 May 2008 17:34:45 +0000</pubDate>
		<dc:creator>frank</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[strip_tags]]></category>

		<guid isPermaLink="false">http://informationideas.com/news/2008/05/19/php-strip_tags-problem/</guid>
		<description><![CDATA[I found that using php function, strip_tags, does not remove all the markup elements correctly from the subject content.Â  First of all, if an anchor link includes a line break, it will not be removed correctly.Â  Also, the style information is not properly removed as well.Â  In the following script, I also added in the [...]]]></description>
			<content:encoded><![CDATA[<p>I found that using php function, strip_tags, does not remove all the markup elements correctly from the subject content.Â  First of all, if an anchor link includes a line break, it will not be removed correctly.Â  Also, the style information is not properly removed as well.Â  In the following script, I also added in the regex to remove any content in between script tags, but that may or may not be necessary.</p>
<p>function strip_all_tags($content)<br />
{<br />
$content = preg_replace(&#8216;/\n/&#8217;,&#8217; &#8216;,$content);<br />
$content = preg_replace(&#8216;/&lt;script.*&lt;\/script&gt;/U&#8217;,&#8217; &#8216;,$content);<br />
$content = preg_replace(&#8216;/&lt;style.*&lt;\/style&gt;/U&#8217;,&#8217; &#8216;,$content);<br />
$content = strip_tags(strtolower($content));<br />
return $content;<br />
}</p>
<p>The function will remove all line breaks so strip_tags will not have problems with finding all markups.Â  Since strip_tags does not remove &lt;style&gt; tags, the new function will remove them using regex.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://informationideas.com/news/2008/05/19/php-strip_tags-problem/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://informationideas.com/news/2008/05/19/php-strip_tags-problem/&amp;title=php+strip_tags+problem" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://informationideas.com/news/2008/05/19/php-strip_tags-problem/&amp;title=php+strip_tags+problem" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://informationideas.com/news/2008/05/19/php-strip_tags-problem/&amp;t=php+strip_tags+problem" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://informationideas.com/news/2008/05/19/php-strip_tags-problem/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://informationideas.com/news/2008/05/19/php-strip_tags-problem/&amp;title=php+strip_tags+problem&amp;summary=I%20found%20that%20using%20php%20function%2C%20strip_tags%2C%20does%20not%20remove%20all%20the%20markup%20elements%20correctly%20from%20the%20subject%20content.%C3%82%C2%A0%20First%20of%20all%2C%20if%20an%20anchor%20link%20includes%20a%20line%20break%2C%20it%20will%20not%20be%20removed%20correctly.%C3%82%C2%A0%20Also%2C%20the%20style%20information%20is%20not%20properly%20removed%20as%20well.%C3%82%C2%A0%20In%20the%20following%20&amp;source=Tech Blog" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://informationideas.com/news/2008/05/19/php-strip_tags-problem/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=php+strip_tags+problem+-+File: /data/app/webapp/functions.php<br />Line: 66<br />Message: Duplicate entry 'ab3fzB' for key 'code'&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://informationideas.com/news/2008/05/19/php-strip_tags-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
