PHP code example of pharaonic / php-diff
1. Go to this page and download the library: Download pharaonic/php-diff library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pharaonic / php-diff example snippets
use Pharaonic\Diff\Diff;
$before = ['name' => 'Ali', 'age' => 30, 'phone' => '0100'];
$after = ['name' => 'Ali', 'age' => 31, 'email' => '[email protected]'];
$result = Diff::between($before, $after);
$result->wasModified('age'); // true
$result->wasAdded('email'); // true
$result->wasRemoved('phone'); // true
$result->hasChanged('name'); // false
echo Diff::text("apple\nbanana\ncherry\n", "apple\nblueberry\ncherry\n")->toUnified();
bash
composer