From 402ddf4859c4e0691aa3eed7d57ad6d1b0a21a9b Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 20 Sep 2006 18:57:05 +0000 Subject: --- system/helpers/array_helper.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'system/helpers') 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 @@ -27,6 +27,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 * -- cgit v1.2.3-24-g4f1b