All pastes #496875 Raw Edit

Someone

public php v1 · immutable
·published 2007-05-19 14:32 UTC
rendered paste body
<?php/*  The inline_diff code was written by Ciprian Popovici in 2004,  as a hack building upon the Text_Diff PEAR package.  It is released under the GPL.*/// the following are taken from Text_Diff v0.0.4require_once 'inline_diff/Diff.php';require_once 'inline_diff/Renderer.php';include_once 'inline_diff/inline_renderer.php';function diff_compute($text1, $text2) {  // prevent html injection  $text1 = htmlentities($text1);  $text2 = htmlentities($text2);  // transform text into array  $lines1 = explode("\n", $text1);  $lines2 = explode("\n", $text2);  // create the diff  $diff = &new Text_Diff($lines1, $lines2);  // create the inline renderer object  $renderer = &new Text_Diff_Renderer_inline();  // render and return the diff  return $renderer->render($diff);}function diff_parse($text) {  // get rid of leading/trailing space  $text = trim($text);  // see if any meaningful text is left  if (!$text) {    return 'The two versions are identical.';  }  $text = nl2br($text);  return '<div class="diff">'.$text.'</div>';}?>