public static function cutStr($str, $length=100, $postfix='...')
    {
        if ( strlen($str) < $length)
            return $str;

        $temp = substr($str, 0, $length);
        return substr($temp, 0, strrpos($temp, ' ') ) . $postfix;
    }
public static function cutStr($str, $length=100, $postfix='...')
    {
        if ( strlen($str) < $length)
            return $str;

        $temp = substr($str, 0, $length);
        return substr($temp, 0, strrpos($temp, ' ') ) . $postfix;
    }
public static function cutStr ( $ str , $ length = 100 , $ postfix = '...' ) { if ( strlen ( $ str ) < $ length ) return $ str ; $ temp = substr ( $ str , 0 , $ length ) ; return substr ( $ temp , 0 , strrpos ( $ temp , ' ' ) ) . $ postfix ; }
Truncates the string to a certain number of characters without breaking words.
@param string $str string
@param int $length max length of string
@param string $postfix postfix
@return string truncated string
Truncates the string to a certain number of characters without breaking words .