class Solution { /** * @param String $s * @return Integer */ function lengthOfLastWord($s) { $words = explode(' ', trim($s)); $lastWord = array_pop($words); return strlen($lastWord); } }
Last updated 1 year ago