public function betterSubstr($str, $length = 0, $minword = 3)
    {
        $sub = '';
        $len = 0;
        foreach (explode(' ', $str) as $word) {
            $part = (($sub != '') ? ' ' : '') . $word;
            $sub .= $part;
            $len += strlen($part);
            if (strlen($word) > $minword && strlen($sub) >= $length) {
                break;
            }
        }
        return $sub . (($len < strlen($str)) ? '...' : '');
    }
public function betterSubstr($str, $length = 0, $minword = 3)
    {
        $sub = '';
        $len = 0;
        foreach (explode(' ', $str) as $word) {
            $part = (($sub != '') ? ' ' : '') . $word;
            $sub .= $part;
            $len += strlen($part);
            if (strlen($word) > $minword && strlen($sub) >= $length) {
                break;
            }
        }
        return $sub . (($len < strlen($str)) ? '...' : '');
    }
public function betterSubstr ( $ str , $ length = 0 , $ minword = 3 ) { $ sub = '' ; $ len = 0 ; foreach ( explode ( ' ' , $ str ) as $ word ) { $ part = ( ( $ sub != '' ) ? ' ' : '' ) . $ word ; $ sub .= $ part ; $ len += strlen ( $ part ) ; if ( strlen ( $ word ) > $ minword && strlen ( $ sub ) >= $ length ) { break ; } } return $ sub . ( ( $ len < strlen ( $ str ) ) ? '...' : '' ) ; }
function betterSubstr
better substring function
@param $str string
@param $length integer
@param $minword integer
@return string
function betterSubstr better substring function