From 323494150a668b4e5f7bb05043b49ebfd93b00e8 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 8 Dec 2010 22:18:50 +0000 Subject: 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 --- engine/lib/elgglib.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engine/lib/elgglib.php') 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; + } } /** -- cgit v1.2.3