$data = [];
$data['fam'] = htmlspecialchars($_POST['fam']);
$data['lschet'] = htmlspecialchars($_POST['lschet']);
$data['c_id'] = htmlspecialchars($_POST['c_id']);
echo json_encode($data);
const file1 = {
host: 'something.io',
timeout: 50,
proxy: '123.234.53.22',
follow: false,
};
const file2 = {
timeout: 20,
verbose: true,
host: 'something.io',
};
const genDiff = (file1, file2) => {
const mergeFiles = { ...file1, ...file2 };
const uniqueKeys = Object.keys(mergeFiles);
const diff = uniqueKeys.map((key, index, arr) => {
if (file1.hasOwnProperty(key) && !file2.hasOwnProperty(key)) {
return { key, value: file1[key], status: 'removed' };
} else if (!file1.hasOwnProperty(key) && file2.hasOwnProperty(key)) {
return { key, value: file2[key], status: 'new' };
} else if (file1.hasOwnProperty(key) && file2.hasOwnProperty(key) && file1[key] === file2[key]) {
return { key, value: file1[key], status: 'same' };
} else if (file1.hasOwnProperty(key) && file2.hasOwnProperty(key) && file1[key] !== file2[key]) {
return { key, value: { oldValue: file1[key], newValue: file2[key] }, status: 'changed' };
}
});
return diff.map((item, index, arr) => {
if (item.status === 'removed') {
console.log(`- ${item.key}: ${item.value}`);
} else if (item.status === 'new') {
console.log(`+ ${item.key}: ${item.value}`);
} else if (item.status === 'same') {
console.log(` ${item.key}: ${item.value}`);
} else if (item.status === 'changed') {
console.log(`- ${item.key}: ${item.value.oldValue}`);
console.log(`+ ${item.key}: ${item.value.newValue}`);
}
});
};
genDiff(file1, file2);