<?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>Algirdas Varnagiris &#187; diff</title>
	<atom:link href="http://www.varnagiris.net/tag/diff/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.varnagiris.net</link>
	<description>The cyber-place where I live</description>
	<lastBuildDate>Thu, 18 Feb 2010 17:19:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to compare text and mark differences using PHP</title>
		<link>http://www.varnagiris.net/2009/04/12/how-to-compare-text-and-mark-differences-using-php/</link>
		<comments>http://www.varnagiris.net/2009/04/12/how-to-compare-text-and-mark-differences-using-php/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 08:09:27 +0000</pubDate>
		<dc:creator>Algirdas</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[diff]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.varnagiris.net/?p=117</guid>
		<description><![CDATA[I was looking for a simple class which will compare to strings and return a result with marked differences. What chars or words where removed and which were added. Just like wiki compare revisions. Actually i googled a lot and finally found a result: The main class which do mostly all the job is Text_Diff, [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a simple class which will compare to strings and return a result with marked differences. What chars or words where removed and which were added. Just like wiki compare revisions. Actually i googled a lot and finally found a result:<br />
The main class which do mostly all the job is Text_Diff, you can download it from <a href="http://pear.php.net/package/Text_Diff/">http://pear.php.net/package/Text_Diff/</a></p>
<p>The other tool I used was <a href="http://software.zuavra.net/inline-diff/">http://software.zuavra.net/inline-diff/</a>. It use Text_Diff and render results.<br />
If you have two strings: &#8220;my blue pen&#8221; and &#8220;my red pen&#8221;, this is the diff and it will produce: &#8220;my &lt;del&gt;blue&lt;/del&gt;&lt;ins&gt;red&lt;/ins&gt; pen&#8221;.<span id="more-117"></span><br />
It does the following:</p>
<ul>
<li>takes two strings</li>
<li>splits each of them into arrays containing one character per entry</li>
<li>considers the two arrays to be &#8220;lines&#8221; and uses Text_Diff from PEAR to compute a diff</li>
<li>it uses my own diff renderer which extends the one from Text_Diff and renders the differences &#8220;inline&#8221; using &lt;del&gt;&lt;/del&gt; and &lt;ins&gt;&lt;/ins&gt; to mark them. These tags are customizable.</li>
<li>finally, it returns the string consisting of the two originals mashed together, with the inline diffs applied.</li>
</ul>
<p>Result example:<br />
If you have two strings: &#8220;my blue pen&#8221; and &#8220;my red pen&#8221;, this is the diff and it will produce: &#8220;my <del>blue</del><ins>red</ins> pen&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.varnagiris.net/2009/04/12/how-to-compare-text-and-mark-differences-using-php/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
