diff options
Diffstat (limited to 'system/core/Input.php')
-rw-r--r-- | system/core/Input.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/system/core/Input.php b/system/core/Input.php index 8d491e055..6690b7f2e 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -153,17 +153,39 @@ class CI_Input { */ protected function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE) { - if ( ! isset($array[$index])) + if (isset($array[$index])) { - return NULL; + $value = $array[$index]; } + elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation + { + $value = $array; + for ($i = 0; $i < $count; $i++) + { + $key = trim($matches[0][$i], '[]'); + if ($key === '') // Empty notation will return the value as array + { + break; + } - if ($xss_clean === TRUE) + if (isset($value[$key])) + { + $value = $value[$key]; + } + else + { + return NULL; + } + } + } + else { - return $this->security->xss_clean($array[$index]); + return NULL; } - return $array[$index]; + return ($xss_clean === TRUE) + ? $this->security->xss_clean($value) + : $value; } // -------------------------------------------------------------------- |