title: Removing forward slash from string is causing some issues in PHP, with substr
body: <p>I'm trying to remove a forward-slash from the end of a string.</p>
  
  <p>Seems simple, but I'm having some issues. A really weird charactar is showing up at the end of the string. See my code:</p>
  
  <pre><code>function removeSlash($currentURL)
  {
  
      if ( strpos($currentURL , '/') == (strlen($currentURL)-1) )
              $currentURL = substr( $currentURL, 0, -1 );
  
      return $currentURL;
  
  }
  
  $url = 'http://bob.com/';
  var_dump( removeSlash($url) );
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>string(15)"http://bob.com"
  </code></pre>
  
  <p>The above <code>var_dump</code> says 15 chars were returned, but there is actually 14...</p>
  
  <p>So I ignore it. Then I write a little more code to store it in a DB. The invisible character emerges!</p>
  
  <p>In phpMyAdmin, when i edit the row that the output was inserted in, this is what shows up (in the text field):</p>
  
  <blockquote>
    <p><a href="http://bob.com" rel="nofollow">http://bob.com</a>�</p>
  </blockquote>
  
  <p>No idea how that's happening. I've tried <code>str_replace()</code>, <code>$var[15] = ''</code> and a load of other methods. All are doing the same!</p>