<?phpclass Solution {/*** @param String $s* @return Integer*/public function lengthOfLastWord($s) {if (!$s) return 0;$len = 0;$s = rtrim($s);for ($i = strlen($s) - 1; $i >= 0; $i--) {if ($s[$i] == ' ') break;$len++;}return $len;}}$s = "Hello World";$cls = new Solution();$r = $cls->lengthOfLastWord($s);print_r($r);
