Viper пишет:/**
* Gets a value from the input data.
*
* @param string $name Name of the value to get or dot-separated path if it's an array.
* @param mixed $default Default value to return if variable does not exist.
* @param string $filter Filter to apply to the value.
* @param boolean $use_path Use $name as dot-separated path to get the array value.
*
* @return mixed The filtered input value.
*/
public function get($name, $default = null, $filter = 'cmd', $use_path = false) {
if ($use_path) {
$data = $this->data;
$keys = explode('.', $name);
if (count($keys) > 1) {
foreach ($keys as $key) {
if (is_array($data) && array_key_exists($key, $data)) {
$data = $data[$key];
} else {
return $default;
}
}
return $this->filter->clean($data, $filter);
} else {
if (array_key_exists($name, $this->data)) {
return $this->filter->clean($this->data[$name], $filter);
}
}
} else {
if (array_key_exists($name, $this->data)) {
return $this->filter->clean($this->data[$name], $filter);
}
}
return $default;
}
Viper, может быть я не до конца осознал все прелести использования ООП, но твою супер функцию можно заменить одной строкой.