Beispiel #1
0
    public function save()
    {
        file_put_contents('checksum' . time() . '.txt', json_encode($this->fileArr));
    }
}
function arrayRecursiveDiff($aArray1, $aArray2)
{
    $aReturn = array();
    foreach ($aArray1 as $mKey => $mValue) {
        if (array_key_exists($mKey, $aArray2)) {
            if (is_array($mValue)) {
                $aRecursiveDiff = arrayRecursiveDiff($mValue, $aArray2[$mKey]);
                if (count($aRecursiveDiff)) {
                    $aReturn[$mKey] = $aRecursiveDiff;
                }
            } else {
                if ($mValue != $aArray2[$mKey]) {
                    $aReturn[$mKey] = $mValue;
                }
            }
        } else {
            $aReturn[$mKey] = $mValue;
        }
    }
    return $aReturn;
}
$oldArr = json_decode(file_get_contents("/var/www/html/checksum1447659829.txt"), true);
$diff = new Diff('/var/www/html/rock/');
$newArr = $diff->getMd5();
$diff->save();
print_r(arrayRecursiveDiff($newArr, $oldArr));