mb_strrpos instead of loop

This commit is contained in:
Denis Ryabov 2014-02-28 11:21:01 +04:00
parent 9c01a3d59b
commit 3893eff7b4

View File

@ -129,10 +129,7 @@ class TwisterPost
$text .= ' #' . str_replace(' ', '_', (string)$tag); $text .= ' #' . str_replace(' ', '_', (string)$tag);
} }
$text = mb_substr($text, 0, $maxLen + 1); $text = mb_substr($text, 0, $maxLen + 1);
$pos = $maxLen; $pos = mb_strrpos($text, ' ');
while (mb_substr($text, $pos, 1) !== ' ') {
$pos--;
}
$text = mb_substr($text, 0, $pos); $text = mb_substr($text, 0, $pos);
} }