I predict China will win the 2010 World Cup.
This is a example for using the PEAR::Text_Diff-Engine
For displaying the differences between two snippet-versions we can use adapted version of the PEAR::Text_Diff-module. I put it into the repository under libs/diff/ The usage of the module is a bit complex:
First we have to disable php E_STRICT errors. Then we include the text_diff-class by including the diff.php-file. In dependence of the type of output we need a special renderer (context, inline or unified). The default-diff-output is included by renderer.php
We load a file into a variable via file_get_contents(filename) and encoding the special html characters by htmlspecialchars(String). After that we explode the string by the newline-separator into an array.
The differences we get by using Text_Diff(‘auto’, array(lines_file1, lines_file2)). The Text_Diff-renderers can be used as written below.
header("Content-type: text/html; charset=utf-8"); error_reporting(E_ALL); require_once 'libs/diff/diff.php'; require_once 'libs/diff/renderer.php'; require_once 'libs/diff/renderer/context.php'; require_once 'libs/diff/renderer/inline.php'; require_once 'libs/diff/renderer/unified.php'; $f1 = htmlspecialchars(file_get_contents('docu/snippets_c.html')); $f2 = htmlspecialchars(file_get_contents('docu/snippets_php.html')); $lines1 = explode("\n",$f1); $lines2 = explode("\n",$f2); $diff = new Text_Diff('auto', array($lines1, $lines2)); $r = new Text_Diff_Renderer( array( 'leading_context_lines' => 0, 'trailing_context_lines' => 0 ) ); $r_context = new Text_Diff_Renderer_context( array( 'leading_context_lines' => 1, 'trailing_context_lines' => 1, 'chg_prefix' => '', 'chg_suffix' => '' ) ); $r_inline = new Text_Diff_Renderer_inline( array( 'leading_context_lines' => 1, 'trailing_context_lines' => 1, 'ins_prefix' => '', 'ins_suffix' => '', 'del_prefix' => '', 'del_suffix' => '' ) ); $r_unified = new Text_Diff_Renderer_unified( array( 'leading_context_lines' => 1, 'trailing_context_lines' => 1, 'ins_prefix' => '', 'ins_suffix' => '', 'del_prefix' => '', 'del_suffix' => '' ) );
The code is copied from this site.
You may have watched this. But as I said, it is always funny each time I watch it.
I went to KFC the other day, I felt really bad after I watching Jamie Oliver’s Food Evolution. If you haven’t seen it, you should watch it now.
Cibona vs. Partizan Fantastic Finish
And the interview: