protected static function _removeLastWord($text)
    {
        $spacepos = mb_strrpos($text, ' ');

        if ($spacepos !== false) {
            $lastWord = mb_strrpos($text, $spacepos);

            // Some languages are written without word separation.
            // We recognize a string as a word if it doesn't contain any full-width characters.
            if (mb_strwidth($lastWord) === mb_strlen($lastWord)) {
                $text = mb_substr($text, 0, $spacepos);
            }

            return $text;
        }

        return '';
    }
protected static function _removeLastWord($text)
    {
        $spacepos = mb_strrpos($text, ' ');

        if ($spacepos !== false) {
            $lastWord = mb_strrpos($text, $spacepos);

            // Some languages are written without word separation.
            // We recognize a string as a word if it doesn't contain any full-width characters.
            if (mb_strwidth($lastWord) === mb_strlen($lastWord)) {
                $text = mb_substr($text, 0, $spacepos);
            }

            return $text;
        }

        return '';
    }
protected static function _removeLastWord ( $ text ) { $ spacepos = mb_strrpos ( $ text , ' ' ) ; if ( $ spacepos !== false ) { $ lastWord = mb_strrpos ( $ text , $ spacepos ) ; // Some languages are written without word separation. // We recognize a string as a word if it doesn't contain any full-width characters. if ( mb_strwidth ( $ lastWord ) === mb_strlen ( $ lastWord ) ) { $ text = mb_substr ( $ text , 0 , $ spacepos ) ; } return $ text ; } return '' ; }
Removes the last word from the input text.

@param string $text The input text
@return string
Removes the last word from the input text .