Browse Source

Utils : méthode limitText (Utils)

reduction
Guillaume 4 years ago
parent
commit
92065e4af8
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      ShopBundle/Services/Utils.php

+ 9
- 0
ShopBundle/Services/Utils.php View File

@@ -148,4 +148,13 @@ class Utils
return in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) ;
}

function limitText($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}

}

Loading…
Cancel
Save