I am using Horde_Text_Diff to compute the difference between two strings. Sample code is as follows:
$check_diff = new Horde_Text_Diff( 'auto', array('asdf','asd11') );
$renderer = new Horde_Text_Diff_Renderer_Inline();
echo $renderer->render($check_diff);
This echoes nothing. The correct behaviour would be to show a difference at character 4.
If I change the comparison array from array('asdf','asd11') to, for instance, array('asdf','12345'), then it will output a1. In other words, it seems only to be comparing the first character. Any ideas?
When I try this, I get two warnings:
I.e., something is getting strings where it expects arrays.
That's because, rather than passing (an array containing) two strings to Horde_Text_Diff(), you should pass (an array containing) two arrays-of-strings (where each string represents a line of text).
If the actual strings you're currently trying to pass in contain multiple lines of text, then you can split them into arrays-of-strings using explode(), e.g.:
which outputs: