Dive into the archives.
- Cutting text , handy php function
I know everybody knows how todo it, but cutting text according to text length is needed almost in any content driven website to avoid breaking design. here is my handy function for cutting text:
function wordcutter($string , $cutnum) {
$wordcutter = strlen($string);
if ($wordcutter > $cutnum) {
$titlecut = substr($string, 0, $cutnum);
$titlecut .= ‘…’;
echo $titlecut;
} else {
echo $string;
}
}
