One thought on “What is the best method to extract a file extension in PHP?

  1. Hello Joe
    Yes there is in fact a very good method to extract the file extension from PHP called pathinfo().
    $ext = pathinfo($filename, PATHINFO_EXTENSION);

    This is a very reliable built in function that is fast and efficient. Pathinfo() is not limited to only providing the file extension but can also provide other information about the file depending on the constant that you pass to it.

Comments are closed.