summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/array_helper.php24
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