title: PHP remove characters after last occurrence of a character in a string
body: <p>So the test case string may be:</p>
  
  <pre><code>http://example.com/?u=ben
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>http://example.com
  </code></pre>
  
  <p>I'm trying to remove everything after the last occurrence of a '/' but only if it's not part of the 'http://'. Is this possible!?</p>
  
  <p>I have this so far:</p>
  
  <pre><code>$url = substr($url, 0, strpos( $url, '/'));
  </code></pre>
  
  <p>But does not work, strips off everything after first '/'.</p>