Last active
February 19, 2020 11:17
-
-
Save helisoncruz/7d49958b46231c27ad4a52951b2d4e2a to your computer and use it in GitHub Desktop.
Function PHP para Limitar Palavras sem cortar
This file contains hidden or 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 limitarTexto($texto, $limite){ | |
$contador = strlen($texto); | |
if ( $contador >= $limite ) { | |
$texto = substr($texto, 0, strrpos(substr($texto, 0, $limite), ' ')) . '...'; | |
return $texto; | |
}else{ | |
return $texto; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment