public function prepare($text, $length = 100, $endString = '...')
    {
        $substring = strip_tags(preg_replace('/<br.?\/?>/', ' ',$text));
        $textLength = mb_strlen($substring);
        
        if($textLength > $length) {
            $lastWordPosition = mb_strpos($substring, ' ', $length);
            
            if($lastWordPosition) {
                $substring = mb_substr($substring, 0, $lastWordPosition);
            } else {
                $substring = mb_substr($substring, 0, $length);
            }
            
            $substring.= $endString;
        }
        
        return $substring;
    }
public function prepare($text, $length = 100, $endString = '...')
    {
        $substring = strip_tags(preg_replace('/<br.?\/?>/', ' ',$text));
        $textLength = mb_strlen($substring);
        
        if($textLength > $length) {
            $lastWordPosition = mb_strpos($substring, ' ', $length);
            
            if($lastWordPosition) {
                $substring = mb_substr($substring, 0, $lastWordPosition);
            } else {
                $substring = mb_substr($substring, 0, $length);
            }
            
            $substring.= $endString;
        }
        
        return $substring;
    }
public function prepare ( $ text , $ length = 100 , $ endString = '...' ) { $ substring = strip_tags ( preg_replace ( '/<br.?\/?>/' , ' ' , $ text ) ) ; $ textLength = mb_strlen ( $ substring ) ; if ( $ textLength > $ length ) { $ lastWordPosition = mb_strpos ( $ substring , ' ' , $ length ) ; if ( $ lastWordPosition ) { $ substring = mb_substr ( $ substring , 0 , $ lastWordPosition ) ; } else { $ substring = mb_substr ( $ substring , 0 , $ length ) ; } $ substring .= $ endString ; } return $ substring ; }
Cuts text to specified length and appends end string.

@param $text
@param int $length
@param string $endString
@return string
Cuts text to specified length and appends end string .