From 62a5ee3e430bd18a8ca8afa0d704967e8bd25763 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 4 Sep 2012 23:12:49 +0200 Subject: More complicated but faster method Also added a comment to explain the reason for such a complicated method --- system/helpers/text_helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { -- cgit v1.2.3-24-g4f1b