Created
January 22, 2012 16:49
-
-
Save luisdalmolin/1657639 to your computer and use it in GitHub Desktop.
Limitando caracteres sem erros de caracteres
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function limitar($string, $tamanho, $encode = 'UTF-8') { | |
if( strlen($string) > $tamanho ) | |
$string = mb_substr($string, 0, $tamanho - 3, $encode) . '...'; | |
else | |
$string = mb_substr($string, 0, $tamanho, $encode); | |
return $string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment