|
chunk of textThis function cuts a string to a set length, and makes sure it doesn't cut a word in half.
// Get a nicely sliced chunk of a text that doesn't cut a word in half.
function getChunkOText($text, $length){
$text = substr($text, 0, $length);
$spaced = false;
while((!$spaced) && $length){
$length--;
if(substr($text, -1) != ' '){
$text = substr($text, 0, $length);
}else{
$text = substr($text, 0, $length);
$spaced = true;
}
}
return $text;
}
|
Spanish proverb
De noche todos los gatos son pardos At night all cats are brown |