function multi_diff($name1, $arr1, $name2, $arr2)
{
    $result = array();
    $merged = $arr1 + $arr2;
    // array_merge($arr1,$arr2);
    foreach ($merged as $k => $v) {
        if (!isset($arr2[$k])) {
            $result[$k] = array($name1 => $arr1[$k], $name2 => NULL);
        } else {
            if (!isset($arr1[$k])) {
                $result[$k] = array($name1 => NULL, $name2 => $arr2[$k]);
            } else {
                if (is_array($arr1[$k]) && is_array($arr2[$k])) {
                    $diff = multi_diff($name1, $arr1[$k], $name2, $arr2[$k]);
                    if (!empty($diff)) {
                        $result[$k] = $diff;
                    }
                } else {
                    if ($arr1[$k] !== $arr2[$k]) {
                        $result[$k] = array($name1 => $arr1[$k], $name2 => $arr2[$k]);
                    }
                }
            }
        }
    }
    return $result;
}
Пример #2
0
function DisplayTheaterCompare()
{
    global $theater, $mod, $theaterfile, $theaterpath, $version, $mod_compare, $theaterfile_compare, $theaterpath_compare, $version_compare;
    $theater_compare = ParseTheaterFile("{$theaterfile_compare}.theater", $mod_compare, $version_compare, $theaterpath_compare);
    $index = "{$version}/{$theaterfile}";
    $index_compare = "{$version_compare}/{$theaterfile_compare}";
    $changes = multi_diff($index, $theater, $index_compare, $theater_compare);
    DisplayStatsHeader();
    echo "<table border='1' cellpadding='2' cellspacing='0'><tr><th>Setting</th><th>{$index}</th><th>{$index_compare}</th></tr>\n";
    $sections = array();
    foreach ($changes as $name => $data) {
        $sections[] = $name;
        if (isset($data[$index]) || isset($data[$index_compare])) {
            echo "<tr><td>" . implode("/", $sections) . "</td>";
            echo "<td>" . printval($data, $index, 0, '-') . "</td>\n";
            echo "<td>" . printval($data, $index_compare, 0, '-') . "</td>\n";
            echo "</tr>\n";
        } else {
            DisplayCompare($data, $sections, $index, $index_compare);
        }
        array_pop($sections);
    }
    closePage(1);
}