Skip to content

Instantly share code, notes, and snippets.

@celsofabri
Created February 24, 2015 19:20
Show Gist options
  • Save celsofabri/82bedc172d7b582390b4 to your computer and use it in GitHub Desktop.
Save celsofabri/82bedc172d7b582390b4 to your computer and use it in GitHub Desktop.
Returns hum summary for any rope word / Retorna um resumo de qualquer string por palavra
/**
* Retorna um resumo de qualquer string por palavra
* @param string $string A string que será cortada
* @param int $max O número máximo de palavras
* @return string A string cortada
* By Cezinha <3
*/
function resumo($string, $max, $final = '...') {
$string = explode(' ', trim($string));
if (count($string) > $max) {
$string = array_slice($string, 0, $max);
$string = implode(' ', $string);
$string .= $final;
}
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment