'ceiling cat', '/\binternet\b/i' => 'intartubez', '/\bhave\b/i' => 'haz', '/\bfood\b/i' => 'fud', '/\bcheese\b/i' => 'cheez', ); $fail = 0; $which = $_POST['which']; if (isset ($which) and preg_match ('|^\d+$|', $which) and $which >= 0 and $which < count ($lolclass)) { # submitted, see if we can display the result. $template = $lolclass[$which]; $words = parse_template ($template); $patterns = array (); $replacements = array (); foreach ($words as $word) { if (isblank ($_POST[$word])) $fail++; else { array_push ($patterns, "/\@$word\@/"); array_push ($replacements, $_POST[$word]); } } print "
\n"; if ($fail) { print "

FAIL

\n"; } else { # so display it $result = preg_replace ($patterns, $replacements, $template); $result = preg_replace (array_keys ($eggs), array_values ($eggs), $result); print "

" . strtoupper($result) . "

\n"; } print "
\n"; } # If the last one worked, choose a different one. if (! $fail) { $last = isset ($which) ? $which : -1; do { $which = rand (0, count ($lolclass) - 1); } while ($last == $which); $words = parse_template ($lolclass[$which]); } print "
\n"; print "
\n"; foreach ($words as $word) { $label = preg_replace ("|_|", " ", $word); $lart = $fail && isblank ($_POST[$word]); if ($lart) print ""; print ucfirst($label) . ": "; if ($lart) print " *"; print "
\n"; } ?>