summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2010-06-11 16:07:03 -0400
committerjim-p <jimp@pfsense.org>2010-06-11 16:07:03 -0400
commit0d90fcaff2d1f32cc0c9b36adf89710542c7670a (patch)
tree72f6abd9b47e12d1f978258fbceda7d6181d84ec /etc
parent7869c580b4c42147bf138b67700e1bada8a7929c (diff)
downloadpfsense-0d90fcaff2d1f32cc0c9b36adf89710542c7670a.zip
pfsense-0d90fcaff2d1f32cc0c9b36adf89710542c7670a.tar.gz
Add array_merge_recursive_unique which was called in xmlrpc.php but did not yet exist. Fixes #645
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/util.inc51
1 files changed, 51 insertions, 0 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 092efde..32846aa 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -1332,4 +1332,55 @@ function is_file_included($file = "") {
return false;
}
+/*
+ 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
+ */
+function array_merge_recursive_unique($array0, $array1)
+{
+ $arrays = func_get_args();
+ $remains = $arrays;
+
+ // We walk through each arrays and put value in the results (without
+ // considering previous value).
+ $result = array();
+
+ // loop available array
+ foreach($arrays as $array) {
+
+ // The first remaining array is $array. We are processing it. So
+ // we remove it from remaing arrays.
+ array_shift($remains);
+
+ // We don't care non array param, like array_merge since PHP 5.0.
+ if(is_array($array)) {
+ // Loop values
+ foreach($array as $key => $value) {
+ if(is_array($value)) {
+ // we gather all remaining arrays that have such key available
+ $args = array();
+ foreach($remains as $remain) {
+ if(array_key_exists($key, $remain)) {
+ array_push($args, $remain[$key]);
+ }
+ }
+
+ if(count($args) > 2) {
+ // put the recursion
+ $result[$key] = call_user_func_array(__FUNCTION__, $args);
+ } else {
+ foreach($value as $vkey => $vval) {
+ $result[$key][$vkey] = $vval;
+ }
+ }
+ } else {
+ // simply put the value
+ $result[$key] = $value;
+ }
+ }
+ }
+ }
+ return $result;
+}
+
?>
OpenPOWER on IntegriCloud