0 Liked

    Simple snippet to get file extension in php

    Following is a simple snippet I use to get a file extension in php, notice that the strrpos function returns the last position of the string “.” in filename in case there are multiple dots in file name.

    After doing some research, I found an easier way to utilize the php function “pathinfo()“. The function returns an array containing information about dirname, basename, extension and filename of a given path string or a filename. The sample code is as follow:

    Leave a Reply

    nineteen + twelve =

    This site uses Akismet to reduce spam. Learn how your comment data is processed.