title: remove spaces from string PHP and insert to database
body: <p>I'm trying to remove spaces from string but only from beggining and end of the string. Everythink work fine but after insert string to database there is no spaces but in the same place is "�".</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$synonimy = $_POST['fsynoms'];
  $synonimyPodzielone = explode( ',', $synonimy );
  for($k=0; $k &lt; count($synonimyPodzielone); $k++)
  {
      for($m=0; $m&lt;strlen($synonimyPodzielone[$k]);$m++)
      {
  
          if($synonimyPodzielone[$k][$m]==" ")
          {
              $synonimyPodzielone[$k][$m]="";
          }
          else
          {
              break;
          }
      }
  }
  </code></pre>
  
  <p>I have also tryied with str_replace trim and same problem.</p>
  
  <p>Any idea how to do that?</p>