public static function ShareaholicUtilities::array_merge_recursive_distinct in Share Buttons, Related Posts, Content Analytics - Shareaholic 7.3
Same name and namespace in other branches
- 8 utilities.php \ShareaholicUtilities::array_merge_recursive_distinct()
Direct copy of the wordpress util function If the two arrays have the same key, the value from array2 overrides the value on array1
Parameters
array $array1:
array $array2:
Return value
array
1 call to ShareaholicUtilities::array_merge_recursive_distinct()
- ShareaholicUtilities::update_options in ./
utilities.php - Update multiple keys of the settings object Works like the Wordpress function for Shareaholic
File
- ./
utilities.php, line 463
Class
Code
public static function array_merge_recursive_distinct(array &$array1, array &$array2) {
$merged = $array1;
foreach ($array2 as $key => &$value) {
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
if (empty($value)) {
$merged[$key] = array();
}
else {
$merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value);
}
}
else {
$merged[$key] = $value;
}
}
return $merged;
}