PHP code example of yperevoznikov / reconciliation
1. Go to this page and download the library: Download yperevoznikov/reconciliation 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/ */
yperevoznikov / reconciliation example snippets
// Use Package
use YPReconciliation\SetsReconciliation;
// Create Reconciliation Algo Class
$reconciliation = new SetsReconciliation();
// Optionally, it's possible to set custom function to create unique identifier
$reconciliation->setUniqueMaskGetterClosure(function($item) {
return $item['name'];
});
// Perform action...
$sourceSet = array(array('name' => 1), array('name' => 2));
$targetSet = array(array('name' => 3));
$result = $reconciliation->getReconciliationActions($sourceSet, $targetSet);
// Remove Elements from $targetSet
foreach ($result->getRemoveList() as $item) {
// remove $item from $targetSet
}
// Add Elements to $targetSet
foreach ($result->getAddList() as $item) {
// add new $item from $targetSet
}
// Sometimes need to update elements in $targetSet , like so
foreach ($result->getUpdateList() as $item) {
// update $item in $targetSet
}