summaryrefslogtreecommitdiffstats
path: root/system/helpers/text_helper.php
diff options
context:
space:
mode:
authorvlakoff <vlakoff@gmail.com>2012-09-04 23:12:49 +0200
committervlakoff <vlakoff@gmail.com>2012-09-04 23:12:49 +0200
commit62a5ee3e430bd18a8ca8afa0d704967e8bd25763 (patch)
tree2aac39c1521de30b16370ab78432b44b2b5b5b66 /system/helpers/text_helper.php
parentcdbcbfc9dac126a87eaa34d411170ce198cb4ffe (diff)
More complicated but faster method
Also added a comment to explain the reason for such a complicated method
Diffstat (limited to 'system/helpers/text_helper.php')
-rw-r--r--system/helpers/text_helper.php3
1 files changed, 2 insertions, 1 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 76dc04a70..b592f3cc0 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -89,7 +89,8 @@ if ( ! function_exists('character_limiter'))
return $str;
}
- $str = preg_replace('/\s+/', ' ', $str);
+ // a bit complicated, but faster than preg_replace with \s+
+ $str = preg_replace('/ {2,}/', ' ', str_replace(array("\r", "\n", "\t", "\x0B", "\x0C"), ' ', $str));
if (strlen($str) <= $n)
{