src/Panda/Support/Helpers/ArrayHelper.php
public static function merge(array $array1, array $array2, $deep = false)
    {
        // Normal array merge
        if (!$deep) {
            return array_merge($array1, $array2);
        }

        // Perform a deep merge
        $merged = $array1;

        foreach ($array2 as $key => $value) {
            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
                $merged[$key] = static::merge($merged[$key], $value, $deep);
            } else if (is_numeric($key)) {
                if (!in_array($value, $merged)) {
                    $merged[] = $value;
                }
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }
public static function merge(array $array1, array $array2, $deep = false)
    {
        // Normal array merge
        if (!$deep) {
            return array_merge($array1, $array2);
        }

        // Perform a deep merge
        $merged = $array1;

        foreach ($array2 as $key => $value) {
            if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
                $merged[$key] = static::merge($merged[$key], $value, $deep);
            } else if (is_numeric($key)) {
                if (!in_array($value, $merged)) {
                    $merged[] = $value;
                }
            } else {
                $merged[$key] = $value;
            }
        }

        return $merged;
    }
public static function merge ( array $ array1 , array $ array2 , $ deep = false ) { // Normal array merge if ( ! $ deep ) { return array_merge ( $ array1 , $ array2 ) ; } // Perform a deep merge $ merged = $ array1 ; foreach ( $ array2 as $ key => $ value ) { if ( is_array ( $ value ) && isset ( $ merged [ $ key ] ) && is_array ( $ merged [ $ key ] ) ) { $ merged [ $ key ] = static :: merge ( $ merged [ $ key ] , $ value , $ deep ) ; } else if ( is_numeric ( $ key ) ) { if ( ! in_array ( $ value , $ merged ) ) { $ merged [ ] = $ value ; } } else { $ merged [ $ key ] = $ value ; } } return $ merged ; }
Perform a merge on the given two arrays.
Deep merge will merge the two arrays in full depth.

@param array $array1
@param array $array2
@param bool  $deep

@return array
Perform a merge on the given two arrays . Deep merge will merge the two arrays in full depth .