Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function abreviaString($texto, $limite, $tres_p = '...')
- {
- $totalCaracteres = 0;
- $vetorPalavras = explode(" ",$texto);
- if(strlen($texto) <= $limite):
- $tres_p = "";
- $novoTexto = $texto;
- else:
- $novoTexto = "";
- for($i = 0; $i <count($vetorPalavras); $i++):
- $totalCaracteres += strlen(" ".$vetorPalavras[$i]);
- if($totalCaracteres <= $limite)
- $novoTexto .= ' ' . $vetorPalavras[$i];
- else break;
- endfor;
- endif;
- return $novoTexto . $tres_p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement