uwc: php implementation
authorNeszt Tibor <neszt@tvnetwork.hu>
Tue, 30 Sep 2014 13:27:35 +0000 (15:27 +0200)
committerNeszt Tibor <neszt@tvnetwork.hu>
Tue, 30 Sep 2014 13:27:35 +0000 (15:27 +0200)
uwc.php [new file with mode: 0644]

diff --git a/uwc.php b/uwc.php
new file mode 100644 (file)
index 0000000..43d8995
--- /dev/null
+++ b/uwc.php
@@ -0,0 +1,22 @@
+<?php
+
+$res = array();
+
+while($f = fgets(STDIN)){
+       preg_match_all("/([a-z']+)/i", $f, $matches, PREG_SET_ORDER);
+       foreach ($matches as $k => $v) {
+               if ( !isset($res[$v[0]]) ) {
+                       $res[$v[0]] = 1;
+               } else {
+                       $res[$v[0]]++;
+               }
+       }
+}
+
+asort($res);
+
+foreach ( $res as $k => $v ) {
+       print "$k $v\n";
+}
+
+?>