diff options
author | vlakoff <vlakoff@gmail.com> | 2012-09-04 23:12:49 +0200 |
---|---|---|
committer | vlakoff <vlakoff@gmail.com> | 2012-09-04 23:12:49 +0200 |
commit | 62a5ee3e430bd18a8ca8afa0d704967e8bd25763 (patch) | |
tree | 2aac39c1521de30b16370ab78432b44b2b5b5b66 /system/helpers | |
parent | cdbcbfc9dac126a87eaa34d411170ce198cb4ffe (diff) |
More complicated but faster method
Also added a comment to explain the reason for such a complicated method
Diffstat (limited to 'system/helpers')
-rw-r--r-- | system/helpers/text_helper.php | 3 |
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) { |