views:

300

answers:

3

Is there a functional String Difference Highlighting class/function out there for PHP?

This has been asked before http://stackoverflow.com/questions/321294/highlight-the-difference-between-two-strings-in-php but the answers given suggest PEAR's Text_Diff.

I tried using Text_Diff and found it was giving me a bunch of STRICT NOTICES and the examples given returned empty strings.

Errors like:

array_walk() expects parameter 2 to be a valid callback, non-static method Text_Diff::trimNewlines() should not be called statically
A: 

I think it means that one or more of the functions that PEAR package uses is not backward compatible with some earlier version(s) of PHP. Maybe just suppress the notice using error_reporting or (dare I say) with the error suppression operator '@'.

karim79
I'm using PHP 5.3 and the errors are for things like: "array_walk() expects parameter 2 to be a valid callback, non-static method Text_Diff::trimNewlines() should not be called statically"
Ian
A: 

You could contact the maintainer of Text_Diff and report the errors. 5.3 is relatively new and it introduces a bunch of changes, so there are many projects that haven't been upgraded yet.

troelskn
Most projects haven't even been updated for PHP5 in general, let alone 5.3 :(
Darryl Hein
A: 

I think you can get something similiar to PEAR class like this: http://phpclasses.byting.at/browse/package/2302.html

FractalizeR