]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Added elgg_get_array_value() helper function.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 1 Jun 2010 19:41:21 +0000 (19:41 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 1 Jun 2010 19:41:21 +0000 (19:41 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@6312 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/lib/elgglib.php

index 7a3e47e7dfec8c43072e6d0209d7ce5f63877026..f890b3518b296ac3d5d3bf5d3209bf1fc369ec9e 100644 (file)
@@ -3419,6 +3419,7 @@ function elgg_walled_garden() {
  *
  * @param string $view_type
  * @return bool
+ * @since 1.7
  */
 function elgg_is_valid_view_type($view_type) {
        global $CONFIG;
@@ -3426,6 +3427,21 @@ function elgg_is_valid_view_type($view_type) {
        return in_array($view_type, $CONFIG->view_types);
 }
 
+/**
+ * Checks for $array[$key] and returns its value if it exists, else
+ * returns $default.
+ *
+ * Shorthand for $value = (isset($array['key'])) ? $array['key'] : 'default';
+ *
+ * @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.
+ * @since 1.8
+ */
+function elgg_get_array_value($key, array $array, $default = NULL) {
+       return (isset($array[$key])) ? $array[$key] : $default;
+}
+
 /**
  * Some useful constant definitions
  */