helpers.php ➔ array_merge_recursive_distinct()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 3
nop 2
dl 0
loc 13
rs 9.5222
c 0
b 0
f 0
1
<?php
2
3
if (! function_exists('array_merge_recursive_distinct')) {
4
    function array_merge_recursive_distinct(array &$array1, array &$array2)
5
    {
6
        $merged = $array1;
7
        foreach ($array2 as $key => &$value) {
8
            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
9
                $merged[$key] = array_merge_recursive_distinct($merged[$key], $value);
10
            } else {
11
                $merged[$key] = $value;
12
            }
13
        }
14
15
        return $merged;
16
    }
17
}
18