Quote:
Originally Posted by rogersnm
PHP Code:
if ($str something) { substr($str, 0, 5); $str = $str . "..."; }
What do i put for if ($str something) to only do that if the string is more than 5 characters long?
|
PHP Code:
if (strlen($str) > 5)
{
//string is greater than 5 chars
}
Also whitespace counts, so you may want to think about trimming the whitespace from the string beforehand.
And here is a list of all php string functions, which could come in handy:
http://us2.php.net/manual/en/ref.strings.php