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