This commit is contained in:
Paula Quispe
2019-04-30 10:39:54 -04:00
parent fac746e497
commit 91da0d6ea4
2 changed files with 15 additions and 15 deletions

View File

@@ -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;