Object difference comparator using array_diff callback.

@param array $array1
@param array $array2
@return array
175456
private static function objectDiffInArrays($array1, $array2)
	{
		return array_udiff($array1, $array2, function($a, $b) {
			if ($a === $b) {
				return 0;
			} elseif ($a < $b) {
				return -1;
			} elseif ($a > $b) {
				return 1;
			}
		});
	}
147717
public static function arrayDiffReplaceRecursive(array $a1, array $a2, $valueIfDelete = null):array
    {
        $diff = [];
        foreach ($a1 as $key => $value) {
            if (!array_key_exists($key, $a2)) {
                $diff[$key] = $valueIfDelete;
            } else { 
                if (!is_array($value) && $value !== $a2[$key]) {
                    $diff[$key] = $a2[$key];
                } else if (is_array($value) && !is_array($a2[$key])) {
                    $diff[$key] = $a2[$key];
                } else if (is_array($value) && is_array($a2[$key])) {
                    $subDiff = self::arrayDiffReplaceRecursive($value, $a2[$key], $valueIfDelete);
                    if ($subDiff !== []) {
                        $diff[$key] = $subDiff;
                    }
                }
                unset($a2[$key]);
            }
        }
        if (count($a2)) {
            $diff = array_merge($diff, $a2);
        }
        return $diff;
    }
1206236
protected static function arrayMergeRecursive($array1, $array2)
	{
		if ( !is_array($array1) || !is_array($array2) ) {
			return $array2;
		}

		foreach ( $array2 as $array2_key => $array2_value ) {
			if ( isset($array1[$array2_key]) ) {
				$array1[$array2_key] = self::arrayMergeRecursive($array1[$array2_key], $array2_value);
			}
			else {
				$array1[$array2_key] = $array2_value;
			}
		}

		return $array1;
	}
1070030
function(array1, array2) {
            // make sure these are actually arrays
            if(!(array1 instanceof Array) || !(array2 instanceof Array)) {
                return false;
            }
            if(array1 === array2) {
                // true if they are the same object
                return true;
            }
            if(array1.length !== array2.length) {
                // false if they are different lengths
                return false;
            }
            // false if any of their elements don't match
            for(var i = 0; i < array1.length; i++) {
                if(array1[i] !== array2[i]) {
                    return false;
                }
            }
            return true;
        }
152969
public function diff($o1, $o2)
    {
        $diff = array();

        foreach ($this->_props as $key=>$prop) {
            if(!$prop->type->equals($o1->get($key), $o2->get($key)))
                $diff []= $key;
        }

        return $diff;
    }
923887
public static function areRecursivelyEquals(array $array1, array $array2)
    {
        if (\count($array1) !== \count($array2)) {
            return false;
        }

        return self::arrayIsContained($array1, $array2);
    }
1297967
protected static function _ArrayObjectMerge (\ArrayObject $array_object, $arrays) {
		$array1 = $array_object->getArrayCopy();
		foreach ($arrays as $array) {
			if (is_array($array)) {
				$array2 = $array;
			} else if ($array instanceof \ArrayObject) {
				$array2 = $array->getArrayCopy();
			} else {
				$array2 = (array) $array;
			}
			$array1 = array_merge($array1, $array2);
		}
		$array_object->exchangeArray($array1);
		return $array_object;
	}
1136764
private static function callbackEquals( $callback1, $callback2 ) {

			if ( is_array( $callback1 ) && is_array( $callback2 ) ) {
				
				if ( count( $callback1 ) == count( $callback2 ) ) {
				
					for ( $i=0, $len = count( $callback1 ); $i<$len; $i++ ) {
						if ( $callback1[$i] != $callback2[$i] ) {
							return false;
						}
					}

					return true;

				} else {
					
					return false;
				
				}

			} else {

				return $callback1 == $callback2;

			}

		}
339420
public static function compare_arrays( $value1, $value2 )
	{
		if ( count( $value1 ) != count( $value2 ) ) return false;

		$types = XBRL_Types::getInstance();

		foreach ( $value1 as $key => $value )
		{
			if ( ! isset( $value2[ $key ] ) ) return false;

			if ( $key == 'id' )
			{
				$pattern = "/^" . SchemaTypes::$ncName . "$/u";
				if ( ! preg_match( $pattern, $value, $matches ) )
				{
					$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value ) );
				}
				if ( ! preg_match( $pattern, $value2[ $key ], $matches ) )
				{
					$this->log()->taxonomy_validation( "context", "id attribute is not a valid NCName", array( 'id' => $value[ $key ] ) );
				}
			}

			if ( is_array( $value ) )
			{
				if ( ! is_array( $value2[ $key ] ) ) return false;

				// These arrays will represent a collection of elements (the key will be 'children') so compare them in order
				if ( ! XBRL_Equality::compare_arrays_ordinal( $value, $value2[ $key ]) )
				{
					return false;
				}

				continue;
			}
			else if ( in_array( $key, array( 'id', 'name', 'prefix', 'type' ) ) )
			{
				if ( $value != $value2[ $key ] )
				{
					return false;
				}

				continue;
			}

			// These can be attribute comparisons so if not the element value look for an attribute and get the type
			$aType = $key == 'value'
				? XBRL_Equality::xequalElementType( $types, $value1['name'], isset( $value1['prefix'] ) ? $value1['prefix'] : null )
				: XBRL_Equality::xequalAttributeType( $types, $key, isset( $value1['prefix'] ) ? $value1['prefix'] : null );

			$bType = $key == 'value'
				? XBRL_Equality::xequalElementType( $types, $value2['name'], isset( $value2['prefix'] ) ? $value2['prefix'] : null )
				: XBRL_Equality::xequalAttributeType( $types, $key, isset( $value2['prefix'] ) ? $value2['prefix'] : null );

			if ( ! XBRL_Equality::xequal( $value, $value2[ $key ], $aType, $bType, $types ) )
			{
				return false;
			}

		}

		return true;
	}
242191
function diffKeys($arr) {
        if($arr instanceof self) {
            $arr = $arr->all();
        }
        
        return (new self(\array_diff_key($this->data, $arr)));
    }
1089118
private static boolean arrayCompare(byte[] a, int offset1, byte[] a2, int offset2, int length) {
        for (int i = 0; i < length; i++) {
            if (a[offset1++] != a2[offset2++]) return false;
        }
        return true;
    }
370378
public static void subtract(double[] array1, double[] array2) {
        assert (array1.length == array2.length);
        for (int i=0; i<array1.length; i++) {
            array1[i] -= array2[i];
        }
    }
606362
public function diff(array $values)
    {
        $copy = $this->withData($values);
        return array_diff_assoc($copy->toArray(), $this->toArray());
    }
1370115
static function compareValues($array1, $array2, $strict = false) {
		if (count($array1) != count($array2)) return false;

		$array1 = array_values($array1);
		$array2 = array_values($array2);
		sort($array1, SORT_STRING);
		sort($array2, SORT_STRING);

		foreach($array1 as $i=>$r) {
			if ($array2[$i] != $r) return false;
			if ($strict and $array2[$i] !== $r) return false;
		}

		return true;
	}
941807
public static function arrayIsContained(array $array1, array $array2)
    {
        foreach ($array1 as $key => $value1) {
            if (!array_key_exists($key, $array2)) {
                return false;
            }
            if (!self::haveTheSameTypeAndValue($value1, $array2[$key])) {
                return false;
            }
        }

        return true;
    }
1171339
function arrayDiff(arrayTarget, arrayCheck) {
    if (!(arrayTarget instanceof Array) || !(arrayCheck instanceof Array)) {
        throw new Error('Both objects have to be an array');
    }

    return arrayTarget.filter(item => !~arrayCheck.indexOf(item));
}
377506
public static function array_merge_deep(array $array1, array $array2)
	{
		$merged = $array1;

		foreach ($array2 as $key => $value) {
			if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
				$merged[$key] = self::array_merge_deep($merged[$key], $value);
			} elseif (is_numeric($key)) {
				// Numeric key. Look at values instead of keys to determine if it already exists.
				if (!in_array($value, $merged)) {
					$merged[] = $value;
				}
			} else {
				$merged[$key] = $value;
			}

		}

		return $merged;
	}