.ins { background: #cfc; } .del { background: #fcc; } ins { background: #9f9; } del { background: #f99; } hr { background: none; border: none; border-top: 2px dotted #000; color: #fff; }
';

echo html_diff($original, $updated);

function html_diff($old, $new)
{
    $diff = simpleDiff::diff_to_array(false, $old, $new, 1);

    $out = '';
    $prev = key($diff);

    foreach ($diff as $i=>$line)
    {
        if ($i > $prev + 1)
        {
            $out .= '';
        }

        list($type, $old, $new) = $line;

        $class1 = $class2 = '';
        $t1 = $t2 = '';

        if ($type == simpleDiff::INS)
        {
            $class2 = 'ins';
            $t2 = '+';
        }
        elseif ($type == simpleDiff::DEL)
        {
            $class1 = 'del';
            $t1 = '-';
        }
        elseif ($type == simpleDiff::CHANGED)
        {
            $class1 = 'del';
            $class2 = 'ins';
            $t1 = '-';
            $t2 = '+';

            $lineDiff = simpleDiff::wdiff($old, $new);

            // Don't show new things in deleted line
            $old = preg_replace('!\{\+(?:.*)\+\}!U', '', $lineDiff);
            $old = str_replace('  ', ' ', $old);
            $old = str_replace('-] [-', ' ', $old);
            $old = preg_replace('!\[-(.*)-\]!U', '\\1', $old);

            // Don't show old things in added line
            $new = preg_replace('!\[-(?:.*)-\]!U', '', $lineDiff);
            $new = str_replace('  ', ' ', $new);
            $new = str_replace('+} {+', ' ', $new);
            $new = preg_replace('!\{\+(.*)\+\}!U', '\\1', $new);
        }

        $out .= '';
        $out .= '';
        $out .= '';
        $out .= '';
        $out .= '';
        $out .= '';
        $out .= '';

        $prev = $i;
    }

    $out .= '

'.($i+1).''.$t1.''.$old.''.$t2.''.$new.'
'; return $out; } ?>