I built a form which asks you to write a word in German and it will tell which definite article you should use.
I used arrays from three questions:
- Cross check if multiple variable are equal in php
- Check if two arrays have the same values
- PHP - Check if two arrays are equal
Here is my code:
<form action="index.php" method="post">
  <input type="text" class="form-control" id="word" name="word" placeholder="Word">    
  <button type="submit" class="btn btn-secondary">See</button>    
</form>
<?php 
 if ($_SERVER['REQUEST_METHOD'] === 'POST') 
 {
  $word = $_POST["word"];
  $das = ["Kind", "Licht", "Mädchen"];
  $der = ["Hund", "Kater", "Mann", "Storm", "Winter"];
  $die = ["Dame", "Frau", "Katze"];
  sort($word);
  sort($das);
  sort($der);
  sort($die);
  if ($word == $das)
  {
     echo "It is a <b>das</b>.";
  }
  elseif ($word == $der) 
  {
     echo "It is a <b>der</b>.";
  }
  else 
   {
     echo "It is a <b>die</b>.";
   }
 }
?>
 
     
     
     
    