<?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>Sean&#039;s Blog &#187; highlight</title>
	<atom:link href="http://seanbehan.com/tag/highlight/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Highlight String in PHP</title>
		<link>http://seanbehan.com/php/highlight-string-in-php/</link>
		<comments>http://seanbehan.com/php/highlight-string-in-php/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 16:57:29 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[file_get_contents]]></category>
		<category><![CDATA[highlight]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=765</guid>
		<description><![CDATA[Function for highlighting text/strings in PHP. $content = file_get_contents(&#34;http://php.net/&#34;); print highlight(&#34;PHP&#34;, $content); function highlight($match, $string){ return str_ireplace($match, &#34;&#38;lt;span style='background:yellow'&#38;gt;$match&#38;lt;/span&#38;gt;&#34;, $string); } Will output something like this ***Notice all the styles are gone :( &#8230; would need to parse the document body to maintain stylesheet and other &#8216;php&#8217; strings that might be in resources paths.]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fphp%2Fhighlight-string-in-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Highlight String in PHP" data-url="http://seanbehan.com/php/highlight-string-in-php/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Function for highlighting text/strings in PHP.</p>
<pre class="wp-code-highlight prettyprint">
$content = file_get_contents(&quot;http://php.net/&quot;);

print highlight(&quot;PHP&quot;, $content);

function highlight($match, $string){
  return str_ireplace($match, &quot;&amp;lt;span style='background:yellow'&amp;gt;$match&amp;lt;/span&amp;gt;&quot;, $string);
}
</pre>
<p>Will output something like this<br />
<div class="wp-caption alignnone" style="width: 355px"><img alt="Highlighted PHP.Net" src="http://farm5.static.flickr.com/4003/4297402799_22d2a0e816_o.jpg" title="PHP Highlight" width="345" height="334" style="background:#eeeeee;padding:3px;border:solid 1px #CCC;"/><p class="wp-caption-text">Highlighted PHP.Net</p></div></p>
<p>***Notice all the styles are gone :( &#8230; would need to parse the document body to maintain stylesheet and other &#8216;php&#8217; strings that might be in resources paths.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/highlight-string-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

