title: How to use preg_replace on a URL
body: <p>How do I use <code>preg_replace</code> text/url. For example, I have a url like this: <code>http://www.web.org/dorama/1201102144/hitoya-no-toge</code>. I just want to show <code>web.org</code>. The url is not always same, for example sometimes it's: <code>http://www.web.org/movies/123/no</code> etc.</p>
  
  <p>I only know the basics of it. Here is what I tried.  It still does not delete the <code>slash</code>.</p>
  
  <pre><code>$url = "http://www.web.org/dorama/1201102144/hitoya-no-toge";
  $patterns = array();
  $patterns[0] = '/http:/';
  $patterns[1] = '/dorama/';
  $patterns[2] = '/1201102144/';
  $replacements = array();
  $replacements[2] = '';
  $replacements[1] = '';
  $replacements[0] = '';
  echo preg_replace($patterns, $replacements, $url);
  </code></pre>
  
  <p>result when i run it <code>//www.web.org///hitoya-no-toge</code></p>