Remove last word from string Any suggestions on better way to remove the last word from a string?

$words = str_word_count($text, 1);
$lastWord = array_pop($words);
$textWithoutLastWord = implode(" ", $words);


or 

$lastSpacePosition = strrpos($text," ");
$textWithoutLastWord =substr($text,0,$lastSpacePosition);
My personal preference would be the second option:

$lastSpacePosition = strrpos($text, ' ');
$textWithoutLastWord = substr($text, 0, $lastSpacePosition);



It's more obvious what's happening. The fact that str_word_count returns an array because you feed it a 1, is not obvious.
The code is shorter, in this case I feel that makes it easier to read, rather than obfuscated.
It is by far the fastest. In my text of 110 words copied from a wikipedia article, with 1e6 iterations

str_word_count version took 17.952 milliseconds.
strrpos took 0.597 milliseconds.
preg_replace (By Oscar M) took 71.189 milliseconds.

In my test text the are letters outside of a-z. The str_word_count solution breaks these letters as if spaces. Whether this is, or is not, the intended behaviour of the function, I would stay away from such behaviour.