Over the course of the next couple of weeks I’m going to place a couple of blogs with a few little PHP Snippets.
These are here more for reference however they are open for discussion so feel free to reply with alternativesor comments or short cuts for my code.
I will try to describe exactly how it works as I go along.
So with this little PHP function you can put a filename into it and it will return you the FILETYPE
$path_info = pathinfo($filename);
So the funtion is quite simply using the PHP function pathinfo()
As you can see you put the name in and pathinfo makes an array and from that you pull the ‘extension’
To call this function :
$filename = ‘thisisanexample.pdf’ ;
$filetype = file_extension(‘$filename’);
Simple as that !