58. Length of Last Word
class Solution {
/**
* @param String $s
* @return Integer
*/
function lengthOfLastWord($s) {
$words = explode(' ', trim($s));
$lastWord = array_pop($words);
return strlen($lastWord);
}
}
Last updated