src/Util/ArrayUtils.php
public static function recursiveDiff($array1, $array2, $caseInsensitive = true, $matchingKeysOnly = true) {

        if ($array1 instanceof AssociativeArray) {
            $array1 = $array1->toArray();
        }

        if ($array2 instanceof AssociativeArray) {
            $array2 = $array2->toArray();
        }

        $sharedKeys = array_intersect(array_keys($array1), array_keys($array2));

        $diffArray = array();

        // Only care about shared keys
        foreach ($sharedKeys as $key) {
            if ((is_array($array1[$key]) || $array1[$key] instanceof AssociativeArray) && (is_array($array2[$key]) || $array2[$key] instanceof AssociativeArray)) {

                $diffArray[$key] = ArrayUtils::recursiveDiff($array1[$key], $array2[$key], $caseInsensitive, $matchingKeysOnly);

            } else {

                $value1 = $caseInsensitive ? strtolower($array1[$key]) : $array1[$key];
                $value2 = $caseInsensitive ? strtolower($array2[$key]) : $array2[$key];

                if ($value1 != $value2) {
                    $diffArray[$key] = array("value1" => $array1[$key], "value2" => $array2[$key]);
                }
            }
        }

        return $diffArray;

    }
public static function recursiveDiff($array1, $array2, $caseInsensitive = true, $matchingKeysOnly = true) {

        if ($array1 instanceof AssociativeArray) {
            $array1 = $array1->toArray();
        }

        if ($array2 instanceof AssociativeArray) {
            $array2 = $array2->toArray();
        }

        $sharedKeys = array_intersect(array_keys($array1), array_keys($array2));

        $diffArray = array();

        // Only care about shared keys
        foreach ($sharedKeys as $key) {
            if ((is_array($array1[$key]) || $array1[$key] instanceof AssociativeArray) && (is_array($array2[$key]) || $array2[$key] instanceof AssociativeArray)) {

                $diffArray[$key] = ArrayUtils::recursiveDiff($array1[$key], $array2[$key], $caseInsensitive, $matchingKeysOnly);

            } else {

                $value1 = $caseInsensitive ? strtolower($array1[$key]) : $array1[$key];
                $value2 = $caseInsensitive ? strtolower($array2[$key]) : $array2[$key];

                if ($value1 != $value2) {
                    $diffArray[$key] = array("value1" => $array1[$key], "value2" => $array2[$key]);
                }
            }
        }

        return $diffArray;

    }
public static function recursiveDiff ( $ array1 , $ array2 , $ caseInsensitive = true , $ matchingKeysOnly = true ) { if ( $ array1 instanceof AssociativeArray ) { $ array1 = $ array1 -> toArray ( ) ; } if ( $ array2 instanceof AssociativeArray ) { $ array2 = $ array2 -> toArray ( ) ; } $ sharedKeys = array_intersect ( array_keys ( $ array1 ) , array_keys ( $ array2 ) ) ; $ diffArray = array ( ) ; // Only care about shared keys foreach ( $ sharedKeys as $ key ) { if ( ( is_array ( $ array1 [ $ key ] ) || $ array1 [ $ key ] instanceof AssociativeArray ) && ( is_array ( $ array2 [ $ key ] ) || $ array2 [ $ key ] instanceof AssociativeArray ) ) { $ diffArray [ $ key ] = ArrayUtils :: recursiveDiff ( $ array1 [ $ key ] , $ array2 [ $ key ] , $ caseInsensitive , $ matchingKeysOnly ) ; } else { $ value1 = $ caseInsensitive ? strtolower ( $ array1 [ $ key ] ) : $ array1 [ $ key ] ; $ value2 = $ caseInsensitive ? strtolower ( $ array2 [ $ key ] ) : $ array2 [ $ key ] ; if ( $ value1 != $ value2 ) { $ diffArray [ $ key ] = array ( "value1" => $ array1 [ $ key ] , "value2" => $ array2 [ $ key ] ) ; } } } return $ diffArray ; }
Return an array of different elements within the 2 arrays.  If matching keys only is supplied, only elements which exist in both but which are different are included.

The returned array contains an associative array for each differing value with a "value1" and "value2" element.

@param $array1
@param $array2

@param bool $matchingKeysOnly
Return an array of different elements within the 2 arrays . If matching keys only is supplied only elements which exist in both but which are different are included .