Is it possible to highlight the modifications in one text paragraph from the other?
For example, there are 3 text fields in a database. Non-admin users can edit the text
Not sure, why these long solutions are there. here I had found an easy one for me.
string1 = "The quick brown fox jumps over the lazy dog.";
$string2 = "The quick brown albino fox jumps the groovy dog.";
$string1 = explode(" ", $string1);
$string2 = explode(" ", $string2);
$diff = array_intersect($string2, $string1);
$tmp = array();
foreach ($string2 as $k => $w) {
if ($diff[$k]==$w) {
$tmp[$k] = $w;
}
else {
$tmp[$k] = "$w";
}
}
$diff = array_diff($string1, $tmp);
foreach ($diff as $k => $w) {
$tmp[$k] .= " [$w]";
}
echo join (' ', $tmp);
ref. https://forums.phpfreaks.com/topic/6525-how-do-i-highlight-differences-between-strings/