Páginas

19/12/2012

[PHP] Abrevia um texto em formato utf8


function abreviaTextoUtf8($txt, $len=10){
  return strlen($txt)>$len?utf8_encode(substr(utf8_decode($txt),0,$len)).'...':$txt;
}
print abreviaTextoUtf8("áéç3", 2);
// resultado: áé

Nenhum comentário: