advanced code snippet search
kirik on 11/11/09
get file extension
11/11/09 08:51pm
1 person have marked this snippet as a favorite
BrianCoyDesign
This function works correct with files with no extension.
function getExtension($filename){ return ('.' . ($ext = pathinfo($filename, PATHINFO_EXTENSION)) == $filename) ? null : $ext;} // Example:var_dump(getExtension('.htaccess'), getExtension('image.jpg'));// Result:// NULL// string(3) "jpg"
Report this snippet Tweet
Comment:
You need to login to post a comment.