title: Why is my php trim() function not working?
body: <p>I'm trying to use trim to remove the underline character from the data that is returned in the $_POST array.  I tried using </p>
  
  <pre><code> $post_Value= str_replace("_", " ", $key) 
  </code></pre>
  
  <p>but the text does not seem to return as one single string.  It's broken between each entry. Then I tried trim like this:  </p>
  
  <pre><code> &lt;?php
  $connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
  
   // Test if connection succeeded
  
   if (mysqli_connect_errno())
      {
      die("Database connection failed: " . mysqli_connect_error() . " (" .  mysqli_connect_errno() . ")");
  }
  
   if (isset($_POST))
      {
      $str = "";
     foreach($_POST as $key =&gt; $value)
      {
      $str = $str . $key . ",";
      }
  
     $post_Value = trim("_", $str);
     }
  
     $query = "UPDATE player_match SET categoryOption='$$post_Value' WHERE id=1";
   ?&gt;
  </code></pre>
  
  <p>When I use the trim function nothing happens it does not remove the <code>_</code> character.  My eventual goal is to put a comma delimited list in my database as a single string.  Why would my <code>trim()</code> function not work in this case?</p>
  
  <p><strong>UPDATE:</strong>  Found <code>&lt;br/&gt;</code> in view page resource so I had to do a combination of the following:</p>
  
  <pre><code>       $post_Value= str_replace("&lt;br_/&gt;", "", $str);
          $post_Value2= str_replace("_", " ", $post_Value);
          $post_Value3= rtrim($post_Value2,",submit,");
          echo $post_Value3;
  
  
          $query="UPDATE player_match SET categoryOption='$post_Value3' WHERE   id=1";
  </code></pre>