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

WBOY
Release: 2016-07-13 10:01:07
Original
837 people have browsed it

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;>
Copy after login

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...
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template