Skip to content

Instantly share code, notes, and snippets.

@luisdalmolin
Created January 22, 2012 16:49
Show Gist options
  • Save luisdalmolin/1657639 to your computer and use it in GitHub Desktop.
Save luisdalmolin/1657639 to your computer and use it in GitHub Desktop.
Limitando caracteres sem erros de caracteres
<?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