Length of last word CODE
<?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;      
by Guram Azarashvili
2 years ago
PHP
Solutions
0
Pro tip: use ```triple backticks around text``` to write in code fences