Get file extension in one line

/ Published in: PHP
Save to your folder(s)

This method is a bit faster and more reliable then using the "explode" method. Works with PHP 4.0.3 and up.

Copy this code and paste it in your HTML
  1. $fileExt = pathinfo('myfile.txt', PATHINFO_EXTENSION); // Returns "txt"

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.