diff options
author | admin <devnull@localhost> | 2006-09-20 20:57:05 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-20 20:57:05 +0200 |
commit | 402ddf4859c4e0691aa3eed7d57ad6d1b0a21a9b (patch) | |
tree | 092a4b13045691ad1c3a144e81fc9820842652e0 | |
parent | 46402b00b8b67c2bd1de380ca14a411118b6f0ff (diff) |
-rw-r--r-- | system/helpers/array_helper.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index cccde1fc4..de0faeeff 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -28,6 +28,30 @@ // ------------------------------------------------------------------------ /** + * Element + * + * Lets you determine whether an array index is set and whether it has a value. + * If the element is empty it returns FALSE (or whater you specify as the default value.) + * + * @access public + * @param string + * @param array + * @param mixed + * @return mixed depends on what the array contains + */ +function element($item, $array, $default = FALSE) +{ + if ( ! isset($array[$item]) OR $array[$item] == "") + { + return $default; + } + + return $array[$item]; +} + +// ------------------------------------------------------------------------ + +/** * Random Element - Takes an array as input and returns a random element * * @access public |