I’m doing this right now in my code to see if a file name has the extension .txt, but I think it basically checks if it contains .txt and not necessarily ends with .txt. Does php have a better way to do extension checking instead of using strpos?
strpos($filename,'.txt') !== false
You can allow multiple extensions by adding to the array.
or a simpler version which allows only txt extensions could be: