function, which limit echo to 150 characters:
[code=php]function limchar($x){return strlen($x)<=150?$x:substr($x,0,150).’…’;} echo limchar($string);[/code]
hope this will help to someone ?
[code=php] /** * limit output length of string, adding ellipsis as needed * @return string * @param string $str * @param integer $max (defaults to 150) */ function limchar($str, $max=150) { return (strlen($str) <= $max) ? $str : substr($str, 0, $max).'…'; } [/code]
[code=php]function limchar($str,$val){return strlen($x)<=$val?$x:substr($x,0,$val).'...';} echo limchar($str,150);[/code]
[code=php]function limchar($str,$val){return strlen($str)<=$val?$x:substr($str,0,$val).'...';} echo limchar($str,150);[/code]
[code=php]function limchar($str,$val){return strlen($str)<=$val?$str:substr($str,0,$val).'...';} echo limchar($str,150); [/code]
Help @gjerich spread the word by sharing this article on Twitter...