Advertisement
tcelestino

Truncando um texto

Apr 20th, 2012
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. <?php
  2. //adicione essa função no seu function.php
  3. function truncationText($txt, $size) {
  4.   if(strlen($txt > $size)) {
  5.     return substr($str_title, $size);
  6.   } else {
  7.     return $txt;
  8.   }
  9. }
  10.  
  11. //como usar//
  12.  
  13. //adicione essa linha no local que irá exibir o titulo
  14. if(function_exists(truncationText)) {
  15.  
  16.     echo truncationText($post->title, 200);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement