Find Longest Word

Find the longest word in a string.

Code

General
$words = explode(' ', $str);
usort($words, fn($a, $b) => strlen($b) - strlen($a));
return $words[0];

Parameters

The string to search

Server

More PHP Snippets