summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-03-01 15:25:02 +0100
committerAndrey Andreev <narf@bofh.bg>2013-03-01 15:25:02 +0100
commit8fcb019ee842718a1e03b5a85b20606072e07d8f (patch)
treef8298e50c25913f4494e9d201508e8b6049ee0d2
parent381cfd9e3ef2c221fbb64e8af570f4949d366db3 (diff)
parentf5b4f6a156cddbed81ee4c4c6c3484507fa58ac5 (diff)
Merge pull request #2294 from vlakoff/develop-2
Text helper: convert_accented_characters() optimization
-rw-r--r--system/helpers/text_helper.php13
1 files changed, 8 insertions, 5 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 54db14f94..b2351db95 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -363,9 +363,9 @@ if ( ! function_exists('convert_accented_characters'))
*/
function convert_accented_characters($str)
{
- static $_foreign_characters;
+ static $array_from, $array_to;
- if ( ! is_array($_foreign_characters))
+ if ( ! is_array($array_from))
{
if (file_exists(APPPATH.'config/foreign_chars.php'))
{
@@ -379,14 +379,17 @@ if ( ! function_exists('convert_accented_characters'))
if (empty($foreign_characters) OR ! is_array($foreign_characters))
{
- $_foreign_characters = array();
+ $array_from = array();
+ $array_to = array();
+
return $str;
}
- $_foreign_characters = $foreign_characters;
+ $array_from = array_keys($foreign_characters);
+ $array_to = array_values($foreign_characters);
}
- return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str);
+ return preg_replace($array_from, $array_to, $str);
}
}