Added, removed, modified and moved values at their exact paths, records matched by ID, redacted secrets, and GitHub-style line diffs.
composer require pharaonic/php-diffuse Pharaonic\Diff\Diff;
$before = ['name' => 'Ali', 'age' => 30, 'phone' => '0100'];
$after = ['name' => 'Ali', 'age' => 31, 'email' => 'ali@example.com'];
$result = Diff::between($before, $after);
$result->wasModified('age'); // true
$result->wasAdded('email'); // true
$result->wasRemoved('phone'); // true
$result->hasChanged('name'); // falseecho Diff::text("apple\nbanana\ncherry\n", "apple\nblueberry\ncherry\n")->toUnified();--- before
+++ after
@@ -1,3 +1,3 @@
apple
-banana
+blueberry
cherryHow to Compare Nested Arrays in PHP: Beyond array_diff()
Full documentation: PHP Diff Documentation.
See SUPPORT.md and SECURITY.md.
MIT. See LICENSE.
