Easy way to get file extension in PHP
I use this code many times in my projects and now I share you this useful code. Sometimes in coding a very simple task can take you a lot of time to make a perfect solution. To get a file extension sometimes take me 30 mins to do the perfect code what work well in all of situation. But now it should take one minute with this code:
PHP Code:
function get_file_extension($file_name) {
return substr(strrchr($file_name,'.'),1);
}
This simple method of file extension retrieval should be reused throughout your code.