Home  >  Article  >  Backend Development  >  A simple way to get the file extension in php, _PHP tutorial

A simple way to get the file extension in php, _PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:01:07815browse

How to simply obtain the file extension in php,

The example in this article describes the simple method of obtaining the file extension in php. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php
 function get_file_extension($file_name)
 {
  /* may contain multiple dots */
  $string_parts = explode('.', $file_name);
  $extension = $string_parts[count($string_parts) - 1];
  $extension = strtolower($extension);
  return $extension;
 }
 $str="img.jpg";
 echo get_file_extension($str);//输出:jpg
&#63;>

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/972628.htmlTechArticleHow to simply obtain the file extension in php. This article describes an example of how to simply obtain the file extension in php. Share it with everyone for your reference. The specific implementation method is as follows: php function...
Statement:
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