mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-04 15:54:00 +01:00
Polyfill added for array_replace_recursive
This is natively available in PHP 5.3+
This commit is contained in:
@@ -128,4 +128,34 @@ function toUTF8noBOM($string,$message) {
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
// Polyfill for array_replace_recursive, which is in PHP 5.3+
|
||||
if (!function_exists('array_replace_recursive')) {
|
||||
function array_replace_recursive($base, $replacements) {
|
||||
foreach (array_slice(func_get_args(), 1) as $replacements) {
|
||||
$bref_stack = array(&$base);
|
||||
$head_stack = array($replacements);
|
||||
|
||||
do {
|
||||
end($bref_stack);
|
||||
|
||||
$bref = &$bref_stack[key($bref_stack)];
|
||||
$head = array_pop($head_stack);
|
||||
|
||||
unset($bref_stack[key($bref_stack)]);
|
||||
|
||||
foreach (array_keys($head) as $key) {
|
||||
if (isset($key, $bref) && is_array($bref[$key]) && is_array($head[$key])) {
|
||||
$bref_stack[] = &$bref[$key];
|
||||
$head_stack[] = $head[$key];
|
||||
} else {
|
||||
$bref[$key] = $head[$key];
|
||||
}
|
||||
}
|
||||
} while(count($head_stack));
|
||||
}
|
||||
|
||||
return $base;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -45,7 +45,7 @@ include(dirname(__FILE__)."/../lang/english.php");
|
||||
$englishText = $text;
|
||||
// Load chosen language ontop to replace English
|
||||
include(dirname(__FILE__)."/../lang/english.php");
|
||||
$text = array_replace_recursive ($englishText, $text);
|
||||
$text = array_replace_recursive($englishText, $text);
|
||||
$_SESSION['text'] = $text;
|
||||
|
||||
// Login not required or we're in demo mode and have password set in our settings, log us straight in
|
||||
|
||||
Reference in New Issue
Block a user