SyntaxFix
Write A Post
Hire A Developer
Questions
If you are looking for a robust version that can deal with any form of URLs, this should do nicely:
<?php $url = "http://foobar.com/foo/bar/1?baz=qux#fragment/foo"; $lastSegment = basename(parse_url($url, PHP_URL_PATH));