lithium\util\Set::contains()

public static method

Determines if the array elements in $array2 are wholly contained within $array1. Works recursively.

Parameters

  • array $array1

    First value.

  • array $array2

    Second value.

Returns

boolean

Returns true if $array1 wholly contains the keys and values of $array2, otherwise, returns false. Returns false if either array is empty.

Source

	public static function contains(array $array1, array $array2) {
		if (!$array1 || !$array2) {
			return false;
		}
		foreach ($array2 as $key => $val) {
			if (!isset($array1[$key]) || $array1[$key] !== $val) {
				return false;
			}
			if (is_array($val) && !static::contains($array1[$key], $val)) {
				return false;
			}
		}
		return true;
	}