If I have a code like this:
$file = basename($filename);
How do I get the file extension of $file? The variable $file could contain any kind of file, like index.php or test.jpeg.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
pathinfo()function:or simply:
You can of course look for the last "." in the filename and get everything after (relatively easy) but why reinvent the wheel?