diff options
| author | 2016-02-09 22:13:57 +0100 | |
|---|---|---|
| committer | 2016-02-09 22:13:57 +0100 | |
| commit | 810b27329492c4050cc1fbbee0c1a0f5ba606280 (patch) | |
| tree | ccdc2430363eafeb52e7ca0856fd5b7eafa12c51 /lib/lib_rss.php | |
| parent | d108eeed124c18710912df7e535cfcbb050d542d (diff) | |
| parent | dfd0b9e9355c1e44e72b95583dd5e730f0ad5230 (diff) | |
Merge pull request #1059 from Alkarex/array_replace_recursive
Compatibility PHP 5.2 with array_replace_recursive
Diffstat (limited to 'lib/lib_rss.php')
| -rw-r--r-- | lib/lib_rss.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 2a23fca45..b0189c162 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')) { //PHP 5.2 + function arr_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 = arr_recurse($array[$key], $value); // overwrite the value in the base array + } + $array[$key] = $value; + } + return $array; + } + function array_replace_recursive($array, $array1) { //http://php.net/manual/function.array-replace-recursive.php#92574 + // 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 = arr_recurse($array, $args[$i]); + } + } + return $array; + } +} + /** * Build a directory path by concatenating a list of directory names. * |
