Posted in php functions
204
3:18 am, October 24, 2021

php get file extension from a file name

this function returns the file extention, however if the file name has multiple . in it this will return a false value.

php get file extension from a file name Demo

View Demo Full Screen View Demo New Tab

php get file extension from a file name Code

PHP

function get_file_extension($file_name) {
	return substr(strrchr($file_name,'.'),1);
}
$my_filename = "kruxor.txt";
echo get_file_extension($my_filename);

Related Tags

No Items Found.

Add Comment
Type in a Nick Name here