PHPプログラムに関する各種メモ書き

PHPで2つのテキストの差分をとる

● jfcherng/php-diff

composer require jfcherng/php-diff

● 差分を取る

$old = 'This is the old string.';
$new = 'And this is the new one.';
$result = \Jfcherng\Diff\DiffHelper::calculate($old, $new, 'Unified'); // Context, JsonText, Unified
var_dump( $result );
No.1970
03/12 20:35

edit