Home > Backend Development > PHP Tutorial > PHP function to get file extension name_PHP tutorial

PHP function to get file extension name_PHP tutorial

WBOY
Release: 2016-07-21 14:55:30
Original
803 people have browsed it

It seems that PHP does not come with a function to obtain the file suffix name. I couldn’t find it in books or online searches, so I wrote a function myself and I can get it easily. Seeing that many friends on the Internet are looking for it, I posted it to share. If you find a better method, be sure to leave a message below to tell me!

The function is as follows:

function gontenfile($filestr){
$gonten= explode('.',$filestr); //Use dots to separate file names into arrays
$gonten = array_reverse($gonten); //Reverse the above array
return $gonten[0]; //Return the first value of the reversed array
}

Use $filename = gontenfile('filename'); This way you can get the suffix of the file.

This article comes from: www.Gonten.com

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364406.htmlTechArticleIt seems that PHP does not have its own function to obtain the file suffix name. I can’t find it in books or online searches. I wrote a function myself and can get it easily. I see many friends on the Internet looking for...
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