Skip to content

Instantly share code, notes, and snippets.

@agilous
Created October 11, 2010 19:23
Show Gist options
  • Save agilous/621067 to your computer and use it in GitHub Desktop.
Save agilous/621067 to your computer and use it in GitHub Desktop.
#!/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