Jump to content

devonc0

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

devonc0's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <html><title>program6</title> <body> <form method="POST" action=" <?php echo $PHP_SELF;?> "> <?php echo "<select name=s>"; for ($count=65; $count<=90; $count++) { echo "<option value=".chr($count).">".chr($count)."</option><br>"; } echo "</select>"; ?> <?php echo "<select name=t>"; for ($count=65; $count<=90; $count++) { echo "<option value=".chr($count).">".chr($count)."</option><br>"; } echo "</select>"; ?> <input type="submit"/> </form> <hr> <?php if (isset($s)) { $first=strtolower($_POST["s"]); $second=strtolower($_POST["t"]); echo "A word that starts with ".$first." and ends with ".$second." is: <br>"; preg_match("/^$first.*%second/i", file('/words'), $words); echo $words[1]; } ?> </body> </html> Ok, so what this program is doing is taking 2 letters (chosen by user from SELECT options) and then calling the php script to search through the 'word' file in the local directory for 3 words that begin with the first option and end with the second: Basically: if user chooses A and T... OUTPUT: Adult, Agincourt, Ant For some reason, I can't wrap my mind around why I can't get this to work, I'm assuming it's the regular expression or something, btw, this is my first day/project using PHP, so PLEASE explain this as if I were mildly slow
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.