From 1b6671d2ae9a88192c47791895bc1b2daa3957c1 Mon Sep 17 00:00:00 2001 From: Yoshi2889 Date: Fri, 18 Aug 2017 00:13:17 +0200 Subject: [PATCH] Cut on words instead of characters Signed-off-by: Yoshi2889 --- src/Aggregator.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Aggregator.php b/src/Aggregator.php index b1f7670..666c997 100755 --- a/src/Aggregator.php +++ b/src/Aggregator.php @@ -317,10 +317,14 @@ public function createSearchResultString(SearchResult $searchResult): string { $description = str_replace("\n", ' ', str_replace("\r", "\n", $description)); - if (strlen($description) > 150) - $str .= substr($description, 0, 150) . '...'; + if (strlen($description) > 200) + { + $description = wordwrap($description, 200); + $str = explode("\n", $description)[0] . '...'; + } else $str .= $description; + $str .= ' - '; }