Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get extension from filename like variable [duplicate]

Tags:

Possible Duplicate:
How to extract a file extension in PHP?

I have a variable $filename="filename.ext" or $filename="filena.m.e.ext" or so on.. How can i extract the extension (here ext) from the variable / string? The variable may change or may have more than one dots.. In that case, i want to get the part after the last dot..

like image 801
Alfred Avatar asked Jun 12 '11 07:06

Alfred


1 Answers

see the answer :

$ext = pathinfo($filename, PATHINFO_EXTENSION); 
like image 189
Haim Evgi Avatar answered Sep 17 '22 18:09

Haim Evgi