Skip to content

Commit 62a5ee3

Browse files
committed
More complicated but faster method
Also added a comment to explain the reason for such a complicated method
1 parent cdbcbfc commit 62a5ee3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

system/helpers/text_helper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ function character_limiter($str, $n = 500, $end_char = '…')
8989
return $str;
9090
}
9191

92-
$str = preg_replace('/\s+/', ' ', $str);
92+
// a bit complicated, but faster than preg_replace with \s+
93+
$str = preg_replace('/ {2,}/', ' ', str_replace(array("\r", "\n", "\t", "\x0B", "\x0C"), ' ', $str));
9394

9495
if (strlen($str) <= $n)
9596
{

0 commit comments

Comments
 (0)