aboutsummaryrefslogtreecommitdiff
path: root/lib/lib_rss.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-01-24 10:18:45 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-01-24 10:18:45 +0100
commitd4a2f6e313f08167ab39f500024593c3e2b4aa5c (patch)
tree111ecbcf9e806847d43ac3f7309b26b44260fd93 /lib/lib_rss.php
parent9637e018bf0bdd17ecfabe825cb12ea9a67d7553 (diff)
Compatibility PHP 5.2 with array_replace_recursive
https://github.com/FreshRSS/FreshRSS/issues/1055 https://github.com/FreshRSS/FreshRSS/pull/926 https://github.com/FreshRSS/FreshRSS/issues/923
Diffstat (limited to 'lib/lib_rss.php')
-rw-r--r--lib/lib_rss.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 2a23fca45..4852f7217 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -15,6 +15,35 @@ if (!function_exists('json_encode')) {
}
}
+if (!function_exists('array_replace_recursive')) {
+ function array_replace_recursive($array, $array1) { //http://php.net/manual/function.array-replace-recursive.php#92574
+ function recurse($array, $array1) {
+ foreach ($array1 as $key => $value) {
+ if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key]))) {
+ $array[$key] = array(); //create new key in $array, if it is empty or not an array
+ }
+ if (is_array($value)) {
+ $value = recurse($array[$key], $value); // overwrite the value in the base array
+ }
+ $array[$key] = $value;
+ }
+ return $array;
+ }
+ // handle the arguments, merge one by one
+ $args = func_get_args();
+ $array = $args[0];
+ if (!is_array($array)) {
+ return $array;
+ }
+ for ($i = 1; $i < count($args); $i++) {
+ if (is_array($args[$i])) {
+ $array = recurse($array, $args[$i]);
+ }
+ }
+ return $array;
+ }
+}
+
/**
* Build a directory path by concatenating a list of directory names.
*