1. Go to this page and download the library: Download rkr/data-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/ */
rkr / data-diff example snippets
use DataDiff\MemoryDiffStorageBuilderFactory;
use DataDiff\MemoryDiffStorage;
$factory = new MemoryDiffStorageBuilderFactory();
$ds = $factory->createBuilder()
->addStringKey('reference')
->addStringValue('name')
->addMoneyValue('price')
->addIntValue('stock')
->build();
foreach($ds->storeB()->getNew() as $row) {
$data = $row->getData();
printf("This row is not present in store a: %s\n", $data['reference']);
}
foreach($ds->storeB()->getMissing() as $row) {
$data = $row->getForeignData();
printf("This row is not present in store a: %s\n", $data['reference']);
}
foreach($ds->storeB()->getChanged() as $row) {
printf("This row is not present in store a: %s\n", $row->getDiffFormatted());
}