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 );

このように表示させることもできます

添付ファイル1
添付ファイル2
No.1970
02/20 15:20

edit

添付ファイル