unkwntech Posted August 13, 2008 Share Posted August 13, 2008 I need to identify the file name in an url, this is not the current url so I can use PHP vars, it is a string submitted from a user. This is what I have: /[a-Z0-9]*\.[a-Z0-9]{2,4} what I'm looking to get is file.ext from http://domain.tld/file.ext Quote Link to comment Share on other sites More sharing options...
Johntron Posted August 13, 2008 Share Posted August 13, 2008 basename( $url ); Example: $url = 'http://www.johntron.com/index.php'; echo basename( $url ); // Output: index.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.