title: string matching via if statement PHP
body: <p>I have an input text area which when filled out and sent, puts whatever was typed in into the variable</p>
  
  <pre><code>$input
  </code></pre>
  
  <p>This is then put through an if statement to check whether or not its the letter a. If it is then echo - you wrote the letter a, else - you did not write the letter a. </p>
  
  <pre><code>&lt;?php    
   $input = $_POST["textarea"];
  
      echo $input;
      echo "&lt;br /&gt;";
  
      if($input = "a"){
      echo "You wrote a";
      }else{
      echo "You did not write a";
      }
  
  
      ?&gt;
  </code></pre>
  
  <p>It does work, but in the wrong way. Every letter I type in comes as 'You wrote a'. I only want it to echo this if the user typed a. Otherwise, echo 'You did not write a' .</p>
  
  <p><strong>EDIT: When I try == instead of = it says 'You did not write a' for everything. Even when I type a.</strong></p>
  
  <p>EDIT 2: When I try the string compare parameter, It didnt work.
   Any suggestions where I am going wrong?</p>
  
  <p>FULL SCRIPTS OF BOTH PAGES:</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;h1&gt;Fun Translator&lt;/h1&gt;
  
  &lt;form method="post" action="query.php"&gt;
   &lt;textarea name="textarea" id="textarea"&gt;
   &lt;/textarea&gt;
   &lt;input type="submit" name="send" value="Translate" /&gt;
  &lt;/form&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>query.php</p>
  
  <pre><code>&lt;?php
  $input = $_POST["textarea"];
  
  echo $input;
  echo "&lt;br /&gt;";
  
  if(strcmp($input,'a')==0){
      echo "You wrote a";
      }else{
      echo "You did not write a";
      }
  
  
  ?&gt;
  </code></pre>
  
  <p>Solution:</p>
  
  <p>trim()</p>