Wanted: PHP Implementation of Unified Diff
For PHPUnit I need a PHP function (written in PHP, an extension would not solve the problem) that
- takes two strings as its input and
- returns a string with the differences between the two string in the same format as GNU diff would return for
diff -ufor two files that contain the respective strings.
Currently I rely on GNU diff being installed on the system that PHPUnit runs on. This thread on the PHPUnit mailinglist shows that this poses a problem.
I know that there is a Text_Diff package in PEAR but it does way more than I need.
28/07/2007 at 14:06 Permalink
Reply
28/07/2007 at 15:46 Permalink
Reply
28/07/2007 at 16:27 Permalink
Reply
28/07/2007 at 19:04 Permalink
Reply
28/07/2007 at 19:43 Permalink
Reply
30/07/2007 at 09:28 Permalink
http://www.holomind.de/phpnet/diff2.src.php
Reply
30/07/2007 at 20:07 Permalink
@Sebastian: Glad you posted this request. I'm interested in the same thing.
Reply
30/07/2007 at 22:03 Permalink
Reply
01/08/2007 at 04:09 Permalink
I haven't tested how fast it is (probably slow right now), and it doesn't print a unified diff (but that shouldn't be too hard to implement) but prints out a modified original diff for space efficiency.
Reply