lithium\util\Set::check()

public static method

Checks if a particular path is set in an array. Tests by key name, or dot-delimited key name, i.e.:


Parameters

  • mixed $data

    Data to check on.

  • mixed $path

    A dot-delimited string.

Returns

boolean

true if path is found, false otherwise.

Source

	public static function check($data, $path = null) {
		if (!$path) {
			return $data;
		}
		$path = is_array($path) ? $path : explode('.', $path);

		foreach ($path as $i => $key) {
			if (is_numeric($key) && (integer) $key > 0 || $key === '0') {
				$key = (integer) $key;
			}
			if ($i === count($path) - 1) {
				return (is_array($data) && isset($data[$key]));
			} else {
				if (!is_array($data) || !isset($data[$key])) {
					return false;
				}
				$data =& $data[$key];
			}
		}
	}