src/sb/Strings.php
public static function truncate($str, $maxlength=20)
    {

        if(strlen($str) > $maxlength){
            $str = substr($str, 0, $maxlength-3).'...';
        }

        return $str;
    }
public static function truncate($str, $maxlength=20)
    {

        if(strlen($str) > $maxlength){
            $str = substr($str, 0, $maxlength-3).'...';
        }

        return $str;
    }
public static function truncate ( $ str , $ maxlength = 20 ) { if ( strlen ( $ str ) > $ maxlength ) { $ str = substr ( $ str , 0 , $ maxlength - 3 ) . '...' ; } return $ str ; }
Truncates a string to a certain length and right padswith ...

@param string $str
@param integer $maxlength The maximum length, keep in mind that the ... counts as three chars
@return string
Truncates a string to a certain length and right padswith ...