Return the Length of the longest word in sentence.

This functions can be used to prevent users from causing overflows with “words” of excessive length.

[php]
function longestWord($sentence){
$arr_words = explode(" ",$sentence);
foreach($arr_words as $eWord){
$eLen = strlen($eWord);
if ($longest < $eLen){
$longest = $eLen;
}
}
return $longest;
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service