So the test case string may be:
http://example.com/?u=ben
Or
http://example.com
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!?
I have this so far:
$url = substr($url, 0, strpos( $url, '/'));
But does not work, strips off everything after first ‘/’.
You should use the tool that is designed for this type of job, parse_url
url.php
Example: