• Page:
  • 1

Character Limit Using PHP

ONLINE

Character Limit Using PHP

2 months, 1 week ago
Hi All,

Someone times we need to short the description or title. We can use word limiter function for this purpose.
But it does not works well in all situation. E.g If in our text no space is present than word limiter can't be use.

In this types of cases you can use following function -

function characterLimiter($string, $length=10,$trailWith='..')
	{
		if(strlen($string)<=$length)
		{
			return $string;
		}
		else
		{
			$y=substr($string,0,$length) . $trailWith;
			return $y;
		}
	}


It is most important in small screens like mobile.

Thanks
Last Edit: 2 months, 1 week ago by Rajat Pal.
  • Page:
  • 1

Upcoming Events

No events found.

Who's Online