title: php is reading extra white space from html form select
body: <p>I have an HTML form that I am parsing over with a PHP script.  One portion of this is a select box, that is populated from a text document.  When I select the option from the box, and echo it out, there seems to be an extra white space that I can not remove.  I have looked at rtrim to remove it but it does not work.</p>
  
  <p>Text Document:</p>
  
  <pre><code>Family
  Buildings
  Paul
  </code></pre>
  
  <p>These were all placed into the document by a script that read input from the user on another form:</p>
  
  <pre><code>&lt;body&gt;
      &lt;form method="post"&gt;
          &lt;input name="album" type="text"&gt;&lt;br&gt;
          &lt;input type="submit" value="add" &gt;
          &lt;input type="button" value="close" onclick="window.close()"&gt;
      &lt;/form&gt;
  &lt;?php
      $file = 'displays.txt';
      $display = $_POST['album'];
      $results = file_put_contents($file, $display . "\n", FILE_APPEND);
  ?&gt;
  </code></pre>
  
  <p>I realize that I use a newline for the files.  That is so that it will correctly populate my form selection.</p>
  
  <p>Selection in form</p>
  
  <pre><code>&lt;?php
      $file = 'displays.txt';
      $contents = file($file);
      foreach($contents as $line) {
          echo'&lt;option value="' . $line . '"&gt;' .$line . '&lt;/option&gt;';
      }
  ?&gt;
  </code></pre>
  
  <p>The following is the code that reads the option input</p>
  
  <pre><code>$album = rtrim($_POST['album'] . '.txt',"\n");
  $pics = array($album);
  </code></pre>
  
  <p>I am adding the ".txt" on afterwards, so that when I send to a python script, I can use it to make a new text document based on their selection.  When I run the everything I get the following for an output:</p>
  
  <pre><code>Array ( [0] =&gt; Carlson .txt [1] =&gt; IMG_2417.JPG [2] =&gt; IMG_3120.JPG )
  </code></pre>
  
  <p>Its the space between Carlson &amp; ".txt", that is throwing me off.  At first I thought I was putting an extra space in as others have done, but when reviewing closley, I do not see any extra space. The next step in the process is to send it over to a python script using shell_exec(), would it just be easier to send the value of "Carlson" over without the ".txt" and add it on the other side?</p>