From e314117563907bef6eaae0c8e3b3d768f701f630 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Mon, 17 Mar 2014 15:05:15 +0400 Subject: [PATCH] fix removing of last tag in short messages --- twisterpost.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/twisterpost.php b/twisterpost.php index c10bb83..1bd3506 100644 --- a/twisterpost.php +++ b/twisterpost.php @@ -138,9 +138,11 @@ class TwisterPost $text .= ' #' . $tagText; } } - $text = mb_substr($text, 0, $maxLen + 1); - $pos = mb_strrpos($text, ' '); - $text = mb_substr($text, 0, $pos); + if(mb_strlen($text) > $maxLen) { + $text = mb_substr($text, 0, $maxLen + 1); + $pos = mb_strrpos($text, ' '); + $text = mb_substr($text, 0, $pos); + } } return $text;