- //Remove U The file name extension
- $url = "Http://sdk.tools.sinaapp.com/index.php?appname=beipiao&version=1" in the RL address;
- function GetFileName ($url) {
- $a = explode ('? ', $url);
- $b = strrpos ($a [0], '. ');//strrpos (the string to be searched for, to find the string, [find where to start]) finds the last occurrence of the string: it returns the last occurrence of the position, or false if not found
- $c = substr ($a [0], $b +1, 3); substr (manipulated string, start position, [end position]) returns a portion of the string
- return $c;
- }
- echo GetFileName ($url).
";
- //second method
- function Getfilenametwo ($url) {
- $a = Parse_url ($url, Php_url_path);//parse_url () parses the URL and returns its components
- $b = pathinfo ($a, pathinfo_extension);//pathinfo ()
- return $b;
- }
- Print_r (Getfilenametwo ($url));
copy code |
File name extension, PHP, URL