lithium\util\Set::check()
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
booleantrue
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];
}
}
}