aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-08 22:18:50 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-08 22:18:50 +0000
commit323494150a668b4e5f7bb05043b49ebfd93b00e8 (patch)
tree52f0718eeeac0934f362567f855ef4d65f7510af /engine
parenteb3057ed8be93c8b26381d6a1d905bc942950f3a (diff)
downloadelgg-323494150a668b4e5f7bb05043b49ebfd93b00e8.tar.gz
elgg-323494150a668b4e5f7bb05043b49ebfd93b00e8.tar.bz2
Added ability to check for empty string in elgg_get_array_value().
git-svn-id: http://code.elgg.org/elgg/trunk@7571 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/elgglib.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 856aa2d36..fe4e3e9d9 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -1946,12 +1946,18 @@ function elgg_set_active_sticky_form($form_name) {
* @param string $key The key to check.
* @param array $array The array to check against.
* @param mixed $default Default value to return if nothing is found.
+ * @param bool $strict Return array key if it's set, even if empty. If false,
+ * return $default if the array key is unset or empty.
*
* @return void
* @since 1.8
*/
-function elgg_get_array_value($key, array $array, $default = NULL) {
- return (isset($array[$key])) ? $array[$key] : $default;
+function elgg_get_array_value($key, array $array, $default = NULL, $strict = true) {
+ if ($strict) {
+ return (isset($array[$key])) ? $array[$key] : $default;
+ } else {
+ return (isset($array[$key]) && !empty($array[$key])) ? $array[$key] : $default;
+ }
}
/**