Revision: 7902
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 20, 2008 12:20 by LondonWeb
Initial Code
define("TRUNC_BEFORE_LENGHT", 0); define("TRUNC_AFTER_LENGHT", 1); function str_truncate($str, $length, $rep=TRUNC_BEFORE_LENGHT){ //adicionada em 27/06/2006 para corrigir um bug if(strlen($str)<=$length) return $str; if($rep == TRUNC_BEFORE_LENGHT) $oc = strrpos(substr($str,0,$length),' '); if($rep == TRUNC_AFTER_LENGHT) $oc = strpos(substr($str,$length),' ') + $length; return substr($str, 0, $oc); } <? $frase = "Então, chapeuzinho vermelho decide tomar no cantinho bem escondida, uma lata de leite condensado."; print str_truncate($frase, 45, TRUNC_AFTER_LENGHT) . '...'; ?>
Initial URL
Initial Description
Para não cortar a palavra ao meio. Its for not to cut a word in the middle. //Ex: Então, chapeuzinho vermelho decide tomar no c... (feio, nao?) Então, chapeuzinho vermelho decide tomar no cantinho...
Initial Title
CortaString - CutString
Initial Tags
Initial Language
PHP