Brendan Murty

Home > Posts > Blurb content

15 Feb 2013

Need to shorten some content so it fits in a small area? My blurb function will shorten any content to the given number of characters.

function blurb($content,$length){
	if($content_length>=$length){// Too long, return the shortened string
		return mb_substr($content,0,$length-3).'...';
	}else{// All good, return the string unchanged
		return $content;