Implementation of DIFF in pure-php

this outputs the difference in gnu diff(1) syntax.
Input-Data: Array
(
    [0] => <html>
    [1] => <head><title>Text</title></head>
    [2] => <body>
    [3] => code a
    [4] => code b
    [5] => code c
    [6] => code d
    [7] => code e
    [8] => code g
    [9] => </body>
    [10] => </html>
)
Array
(
    [0] => <html>
    [1] => <head><title>Text2</title></head>
    [2] => <body>
    [3] => code a
    [4] => code a
    [5] => code c
    [6] => code d
    [7] => code e
    [8] => code g
    [9] => code f
    [10] => </body>
    [11] => </html>
)

new, old
2c2 < Text --- > Text2 5c5 < code b --- > code a 9a10 > code f
old, new
2c2 < Text2 --- > Text 5c5 < code a --- > code b 10d9 < code f
Compared: array_diff( $f1_arr, $f2_arr );
Array ( [1] => <head><title>Text</title></head> [4] => code b )
Compared: array_diff( $f2_arr, $f1_arr );
Array ( [1] => <head><title>Text2</title></head> [9] => code f )

© 2003-2006 Daniel Unterberger. view source .