title: PHP - using a line from a text file in an IF statement
body: <p>I am trying to get a PHP file to read a specific line from a text file and then use that line in a string comparison for an if statement.<br>
  The second line in the textfield will always have one of two different values. Either <code>&amp;activeGame=0</code> or <code>&amp;activeGame=1</code>.</p>
  
  <p>The textfile:  </p>
  
  <pre><code>boardarray=["NV", "SB", "VB", "NV"]  
  &amp;activeGame=1  
  &amp;activePlayer=V  
  </code></pre>
  
  <p>The PHP-file:  </p>
  
  <pre><code>$theFile = "test.txt";
  $line = file($theFile);
  echo $line[1]; //This will output "&amp;activeGame=1" without quotation marks
  
  if ($line[1] == "&amp;activeGame=1") {
      echo "The game is active";
  } else {
      echo "The game is not active";
  }
  </code></pre>
  
  <p>Since <code>echo $line[1]</code> outputs <code>&amp;activeGame=1</code> I know that the PHP script can read the data from the text file.<br>
  The problem is that the if function will echo <code>"The game is not active"</code> and I cant figure out why. </p>
  
  <p><strong>EDIT</strong><br>
  <strong>SOLUTION:</strong></p>
  
  <pre><code>$theFile = "test.txt";
  $line = file($theFile);
  echo $line[1]; //This will output "&amp;activeGame=1" without quotation marks
  
  if (trim($line[1]) == "&amp;activeGame=1") { 
      echo "The game is active";
  } else {
      echo "The game is not active";
  }
  </code></pre>
  
  <p>The trim function on row 5 is what was missing.</p>