Home > Backend Development > PHP Tutorial > PHP method to get file extension from given url, _PHP tutorial

PHP method to get file extension from given url, _PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:03:45
Original
1001 people have browsed it

How php gets the file extension from a given url,

The example in this article describes how php gets the file extension from a given url. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php
/**
 * 给定url,获取文件后缀
 * @param string $url
 * @return string
 */
function getUrlPostfix ($url)
{
  $url_arr = explode('.', $url);
  $postfix = $url_arr[count($url_arr) - 1];
  $substr = substr($postfix, 0, 3);
  return $substr;
}
$url = "http://www.bkjia.com/index.html&#63;id=1";
$str = getUrlPostfix($url);
echo $str . "\n";
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/967738.htmlTechArticleHow to get the file extension in php from a given url. This example describes how to get the file extension in php from a given url. Name method. Share it with everyone for your reference. The specific implementation method is as follows: p...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template