This commit is contained in:
Paula Quispe
2019-01-23 08:10:28 -04:00
parent 595d87d3d1
commit 71b76fce61
2 changed files with 49 additions and 14 deletions

View File

@@ -400,6 +400,37 @@ function verifyCsrfToken($request)
}
}
/**
* Get the difference between to multidimensional array
*
* @param array $array1
* @param array $array2
*
* @return array
*/
function arrayDiffRecursive(array $array1, array $array2)
{
$difference = [];
foreach ($array1 as $key => $value) {
if (is_array($value)) {
if (!isset($array2[$key])) {
$difference[$key] = $value;
} elseif (!is_array($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;
}
}
return $difference;
}
/**
* Get the current user CSRF token.
*