$a) { $c = substr($a, 0, 1); $c2 = substr($a, 0, 2); $c3 = substr($a, 0, 3); echo ''; if (($c3 == '+++') || ($c3 == '---')) { echo ''.html_format($a).''; } else if ($c2 == '@@') { echo ''.html_format($a).''; } else if ($c == '+') { echo ''.html_format($a).''; } else if ($c == '-') { echo ''.html_format($a).''; } else { echo html_format($a); } echo "
\n"; } } function output_diff($fileA, $fileB, $num_lines=3) { $fileA = realpath($fileA); $fileB = realpath($fileB); ob_start(); system("diff -wbB --ignore-blank-lines ".escapeshellarg($fileA)." ".escapeshellarg($fileB)); $cont = ob_get_contents(); ob_end_clean(); $ary = explode("\n", $cont); foreach ($ary as $n => $a) { $c = substr($a, 0, 1); echo ''; if (($c == '>') || ($c == '<')) { echo ''.html_format($c).''.html_format(substr($a, 1)); } else { echo ''.html_format($a).''; } echo "
\n"; } } function html_format($x) { $x = htmlentities($x); $x = str_replace("\t", str_repeat(' ', TABS_WS), $x); $x = str_replace(' ', ' ', $x); return $x; }