Created
October 11, 2010 19:23
-
-
Save agilous/621067 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
// Submitted by Karl Wilbur @karlwilbur | |
<?php | |
$filename = $_SERVER['argv'][1]; | |
if (!file_exists($filename)) die('File "'.$filename.'" does not exist.'); | |
if (!is_readable($filename)) die('File "'.$filename.'" is not readable.'); | |
error_reporting(0); | |
$words = array(); | |
$lines = file($filename); | |
foreach ( $lines as $line) { | |
$line = rtrim($line); | |
$words[$line] = 0; | |
preg_match_all("|[^aeiou]+|",$line,$matches); | |
foreach($matches[0] as $v) | |
$words[$line] = max($words[$line],strlen($v)); | |
} | |
asort($words); | |
$longest = array_pop(array_keys($words)); | |
echo $longest."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment