title: How do I get preg_match to output a specific part of a URL?
body: <p>Okay, if I have the URL <code>http://hello.com/api/thispart.php</code></p>
  
  <p>How to I get the preg_match() function to select just <code>thispart</code></p>
  
  <p>So far I am looking at </p>
  
  <pre><code>preg_match('@^(?:http://)?([^/]+)@', "http://hello.com/api/thispart.php", $matches)
  echo " &lt;br&gt;Domain name is: $matches[0] &lt;br&gt;";
  echo " &lt;br&gt;Domain name is: $matches[1];
  </code></pre>
  
  <p>The output is </p>
  
  <pre><code>Domain name is: http://hello.com
  
  Domain name is: hello.com 
  </code></pre>
  
  <p>But I just want it to output <code>thispart</code></p>