fork(1) download
  1. <?php
  2. function longestWord($txt) {
  3. $words = preg_split('#[^a-z0-9áéíóúñç]#i', $txt, -1, PREG_SPLIT_NO_EMPTY);
  4. usort($words, function($a, $b) { return strlen($b) - strlen($a); });
  5. return $words[0];
  6. }
  7. echo longestWord("Where did the big Elephant go?");
  8. // prints Elephant
  9. ?>
Success #stdin #stdout 0.03s 52432KB
stdin
Standard input is empty
stdout
Elephant