diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index b9c45014ece300b555a57d5142f4f63b4cec5924..48c3e8a5d252d170335b5267525a2ac560acb419 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -157,6 +157,64 @@ struct ast_custom_function regex_function = {
 	.read = builtin_function_regex,
 };
 
+static void builtin_function_array(struct ast_channel *chan, char *cmd, char *data, const char *value)
+{
+	char *varv[100];
+	char *valuev[100];
+	char *var, *value2;
+	int varcount, valuecount, i;
+
+	var = ast_strdupa(data);
+	value2 = ast_strdupa(value);
+	if (!var || !value2) {
+		ast_log(LOG_ERROR, "Out of memory\n");
+		return;
+	}
+
+	/* The functions this will generally be used with are SORT and ODBC_*, which
+	 * both return comma-delimited lists.  However, if somebody uses literal lists,
+	 * their commas will be translated to vertical bars by the load, and I don't
+	 * want them to be surprised by the result.  Hence, we prefer commas as the
+	 * delimiter, but we'll fall back to vertical bars if commas aren't found.
+	 */
+	if (strchr(var, ',')) {
+		varcount = ast_app_separate_args(var, ',', varv, 100);
+	} else {
+		varcount = ast_app_separate_args(var, '|', varv, 100);
+	}
+
+	if (strchr(value2, ',')) {
+		valuecount = ast_app_separate_args(value2, ',', valuev, 100);
+	} else {
+		valuecount = ast_app_separate_args(value2, '|', valuev, 100);
+	}
+
+	for (i = 0; i < varcount; i++) {
+		if (i < valuecount) {
+			pbx_builtin_setvar_helper(chan, varv[i], valuev[i]);
+		} else {
+			/* We could unset the variable, by passing a NULL, but due to
+			 * pushvar semantics, that could create some undesired behavior. */
+			pbx_builtin_setvar_helper(chan, varv[i], "");
+		}
+	}
+}
+
+#ifndef BUILTIN_FUNC
+static
+#endif
+struct ast_custom_function array_function = {
+	.name = "ARRAY",
+	.synopsis = "Allows setting multiple variables at once",
+	.syntax = "ARRAY(var1[,var2[...][,varN]])",
+	.write = builtin_function_array,
+	.desc =
+"The comma-separated list passed as a value to which the function is set\n"
+"will be interpreted as a set of values to which the comma-separated list\n"
+"of variable names in the argument should be set.\n"
+"Hence, Set(ARRAY(var1,var2)=1,2) will set var1 to 1 and var2 to 2\n",
+};
+
 static char *builtin_function_len(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
 	int length = 0;