PMC-748
This commit is contained in:
@@ -401,27 +401,27 @@ function verifyCsrfToken($request)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the difference between to multidimensional array
|
||||
* Get the difference between to arrays
|
||||
* If the element is an array we will to keep the value from $array1
|
||||
* If the element is an object we will to keep the value from $array1
|
||||
*
|
||||
* @param array $array1
|
||||
* @param array $array2
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function arrayDiffRecursive(array $array1, array $array2)
|
||||
*/
|
||||
function getDiffBetweenModifiedVariables(array $array1, array $array2)
|
||||
{
|
||||
$difference = [];
|
||||
foreach ($array1 as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if (!isset($array2[$key])) {
|
||||
if ($value !== $array2[$key]) {
|
||||
$difference[$key] = $value;
|
||||
} elseif (!is_array($array2[$key])) {
|
||||
}
|
||||
} elseif (is_object($value)) {
|
||||
// When using ===, it means object variables are identical and they refer to the same instance of the same class.
|
||||
if ($value != $array2[$key]) {
|
||||
$difference[$key] = $value;
|
||||
} else {
|
||||
$new_diff = arrayDiffRecursive($value, $array2[$key]);
|
||||
if (!empty($new_diff)) {
|
||||
$difference[$key] = $new_diff;
|
||||
}
|
||||
}
|
||||
} elseif (!isset($array2[$key]) || $array2[$key] != $value) {
|
||||
$difference[$key] = $value;
|
||||
|
||||
Reference in New Issue
Block a user