Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php get long word in array

function longestWord($txt) {
    $words = preg_split('#[^a-z0-9áéíóúñç]#i', $txt, -1, PREG_SPLIT_NO_EMPTY);
    usort($words, function($a, $b) { return strlen($b) - strlen($a); });
    return $words[0];
}
echo longestWord("Where did the big Elephant go?");
// prints Elephant
Comment

PREVIOUS NEXT
Code Example
Php :: laravel helper.php session data 
Php :: php artisan reset --force 
Php :: how to delete single row from grid in magento 
Php :: dot after each character php 
Php :: Laravel hasmany withSum() 
Php :: herencia php 
Php :: Modal Edit Specific/Same table row, where button is 
Php :: get next day date in php 
Php :: Secured PHP Contact Form 
Php :: search a file name and open that file phpstrom 
Php :: php browser detection script 
Php :: Generate slug 
Php :: Laravel Cache store [none] is not defined. 
Php :: twig global 
Php :: build_Assoc 
Php :: use app http models in laravel 8 
Php :: 12 months service expiary in php 
Php :: check which php.ini file enabled from code 
Php :: make_dpcust 
Php :: remove public from laravel url live 
Php :: assertequals vs assertsame 
Php :: undefined function bcmul php linux 
Php :: laravel import csv files 
Php :: what returns livewire mount 
Php :: laravel retain old value 
Php :: Get page title, excerpt or content by Name of the Page 
Php :: display page template using functions.php 
Php :: set count down CLI php 
Php :: Ciclo for PHP ejemplos 
Php :: Add class to menu anchors 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =