summaryrefslogtreecommitdiffstats
path: root/etc/inc/util.inc
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2013-09-03 12:35:13 -0300
committerRenato Botelho <garga@FreeBSD.org>2013-09-03 13:36:00 -0300
commitc59e21b5c706b46159ecc19b33977299754b07b9 (patch)
tree8daa4fcd1fc9c7f7977e6687c5358d3eeee215b5 /etc/inc/util.inc
parent7050776a100b4dada4b0865c1bfe99906551e29f (diff)
downloadpfsense-c59e21b5c706b46159ecc19b33977299754b07b9.zip
pfsense-c59e21b5c706b46159ecc19b33977299754b07b9.tar.gz
Fix #3004:
. Create a function to replace strings on deep associative arrays . Use the recent created function array_replace_values_recursive to fix VIP interface names instead of touch config.xml directly
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r--etc/inc/util.inc16
1 files changed, 16 insertions, 0 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index d6d05ac..6a62563 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -1778,6 +1778,22 @@ function is_file_included($file = "") {
}
/*
+ * Replace a value on a deep associative array using regex
+ */
+function array_replace_values_recursive($data, $match, $replace) {
+ if (empty($data))
+ return $data;
+
+ if (is_string($data))
+ $data = preg_replace("/{$match}/", $replace, $data);
+ else if (is_array($data))
+ foreach ($data as $k => $v)
+ $data[$k] = array_replace_values_recursive($v, $match, $replace);
+
+ return $data;
+}
+
+/*
This function was borrowed from a comment on PHP.net at the following URL:
http://www.php.net/manual/en/function.array-merge-recursive.php#73843
*/
OpenPOWER on IntegriCloud