title: Cleaning a URL with PHP
body: <p>I've been looking though google and stackflow for an answer for this and testing a few finds but I still can't get this working. </p>
  
  <p>All of these end my link at a space. For example <a href="http://www.website.com/movies/movie" rel="nofollow">www.website.com/movies/movie</a> <br>
  Where I'm trying to get it to read <a href="http://www.website.com/movies/movie%20with%20spaces%20here.mp4" rel="nofollow">www.website.com/movies/movie with spaces here.mp4</a></p>
  
  <pre><code>$namehref = "movie/" . $dirArray[$index]. " download";
  
  $DoStream = "&lt;a href=" . $the_dir . "&gt;Watch&lt;/a&gt;";
  $DoDownload = "&lt;a href=" . $the_dir . "&gt;Download&lt;/a&gt;";
  </code></pre>
  
  <hr>
  
  <p>However this code does <strong>not</strong> remove the spaces???</p>
  
  <pre><code>$name = $dirArray[$index];
  $movienameonly = substr($name, 0, -4);
  </code></pre>
  
  <p>example www.website.com/movies/movie with spaces here</p>
  
  <hr>
  
  <p>So my questions are - Why does the first section of code remove the spaces and how do I correct it. In addition to spaces I also hit errors with 's as well.  <br>
  <em>example They're here.mp4</em></p>