<?php
function lengthOfLastWord1($s) {
$words = str_word_count($s,1); //returns words in array
//(function returns an array with the words from the string)
$wordCount = str_word_count($s); //counts words in text
$lastW = $words[$wordCount-1];//returns last word
$lastWLen = strlen($lastW); //The last word length
$lastResult = "The last word is ".'"'.$lastW.'"'." with length $lastWLen";
return $lastWLen;
return $lastResult;